-/* THIS SAMPLE CODE IS PROVIDED AS IS AND IS SUBJECT TO ALTERATIONS. FUJITSU */\r
-/* MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR */\r
-/* ELIGIBILITY FOR ANY PURPOSES. */\r
-/* (C) Fujitsu Microelectronics Europe GmbH */\r
-/*------------------------------------------------------------------------\r
- MAIN.C\r
- - description\r
- - See README.TXT for project description and disclaimer.\r
-\r
- 06.10.06 1.01 UMa changed includes\r
--------------------------------------------------------------------------*/\r
-\r
- \r
-/*************************@INCLUDE_START************************/\r
-#include "mb91465k.h"\r
-#include "vectors.h"\r
-#include "RLT.h"\r
-#include "Flash.h"\r
-/**************************@INCLUDE_END*************************/\r
-\r
-/*********************@GLOBAL_VARIABLES_START*******************/\r
-/**********************@GLOBAL_VARIABLES_END********************/\r
-\r
-\r
-/*******************@FUNCTION_DECLARATION_START*****************/\r
-\r
-/*********************@FUNCTION_HEADER_START*********************\r
-*@FUNCTION NAME: main() *\r
-* *\r
-*@DESCRIPTION: The main function controls the program flow *\r
-* *\r
-*@PARAMETER: none *\r
-* *\r
-*@RETURN: none *\r
-* *\r
-***********************@FUNCTION_HEADER_END*********************/\r
-\r
-\r
-void main(void)\r
-{\r
- unsigned char error = 0;\r
- unsigned char global_error = 0; \r
- unsigned int i;\r
- \r
- /* Enable Clock Monitor */\r
- CSCFG_MONCKI = 1;\r
- CMCFG = 0x0D;\r
- \r
- __EI(); /* enable interrupts */\r
- __set_il(31); /* allow all levels */\r
- InitIrqLevels(); /* init interrupts */\r
-\r
- PORTEN = 0x3; /* enable I/O Ports */\r
- /* This feature is not supported by MB91V460A */\r
- /* For all other devices the I/O Ports must be enabled*/\r
-\r
- /* Enable LEDs */\r
- DDR27 = 0xFF;\r
- PDR27 = 0x00;\r
-\r
- /* Initialize Reload Timer Channel 0 */\r
- RLT_InitializeTimer(0, RLT_RUMMODE_RELOAD, RLT_CLOCKMODE_DIV32, RLT_TRIGGER_SOFTWARE, RLT_OUTOUTMODE_HIGHLEVEL);\r
- RLT_SetReloadValue(0,0x1388); // CLKP/32, 0.01s Interval => 0x1388 counts\r
- RLT_EnableInterrupt(0);\r
- RLT_TriggerTimer(0);\r
- \r
- /* Initialize UART4 */\r
- InitUart4();\r
-\r
- /* Output Welcome Message */\r
- Puts4(" \n\n");\r
- Puts4("\n\n********** Welcome to FUJITSU FLASH Programming Demo **********\n");\r
-\r
- /* Do BlankCheck on Sector at 0xA0000 */\r
- Puts4("Blank Check of FLASH Sector at 0xA0000 ... ");\r
- error = FLASH_SectorBlankCheck(0xA0000, 0x4000);\r
- if( error == 1 )\r
- {\r
- Puts4("done.\n");\r
- }\r
- else\r
- {\r
- Puts4("failed.\n");\r
- }\r
- \r
- /* Show Current Content of 0xA0000 ... 0xA001F */\r
- i=0;\r
- Puts4("\nCurrent Content of FLASH at 0xA0000 ... 0xA001F:\n");\r
- while(i < 0x20)\r
- {\r
- Puts4("0x"); Puthex4( *(unsigned char *)(0xA0000 + i), 2); Puts4(" ");\r
- i++;\r
- if( (i % 0x10) == 0 ) Puts4("\n");\r
- }\r
- Puts4("\n");\r
- \r
- /* SectorErase of FLASH Memory 0xA0000*/\r
- Puts4("Sector Erase of 0xA0000 ... ");\r
- error = FLASH_SectorErase(0xA0000);\r
- error = FLASH_SectorErase(0xA0004);\r
- if( error == 1 )\r
- {\r
- Puts4("done.\n");\r
- }\r
- else\r
- {\r
- global_error = 1;\r
- Puts4("failed.\n");\r
- }\r
-\r
- /* Do BlankCheck on Sectors at 0xA0000 */\r
- Puts4("Blank Check of FLASH Sector at 0xA0000 ... ");\r
- error = FLASH_SectorBlankCheck(0xA0000, 0x4000);\r
- if( error == 1 )\r
- {\r
- Puts4("done.\n");\r
- }\r
- else\r
- {\r
- global_error = 1;\r
- Puts4("failed.\n");\r
- }\r
- \r
- /* Show Current Content of 0xA0000 ... 0xA001F */\r
- i=0;\r
- Puts4("\nCurrent Content of FLASH at 0xA0000 ... 0xA001F:\n");\r
- while(i < 0x20)\r
- {\r
- Puts4("0x"); Puthex4( *(unsigned char *)(0xA0000 + i), 2); Puts4(" ");\r
- i++;\r
- if( (i % 0x10) == 0 ) Puts4("\n");\r
- }\r
- Puts4("\n");\r
- \r
- /* Write 0x55AA to 0xA0002 */\r
- Puts4("Write 0x55AA to 0xA0002 ... ");\r
- error = FLASH_WriteHalfWord(0xA0002,0x55AA);\r
- if( error == 1 )\r
- {\r
- Puts4("done.\n");\r
- }\r
- else\r
- {\r
- global_error = 1;\r
- Puts4("failed.\n");\r
- }\r
-\r
- /* Write 0x33CC to 0xA0004 */\r
- Puts4("Write 0x33CC to 0xA0004 ... ");\r
- error = FLASH_WriteHalfWord(0xA0004,0x33CC);\r
- if( error == 1 )\r
- {\r
- Puts4("done.\n");\r
- }\r
- else\r
- {\r
- global_error = 1;\r
- Puts4("failed.\n");\r
- }\r
- \r
- /* Show Current Content of 0xA0000 ... 0xA001F */\r
- i=0;\r
- Puts4("\nCurrent Content of FLASH at 0xA0000 ... 0xA001F:\n");\r
- while(i < 0x20)\r
- {\r
- Puts4("0x"); Puthex4( *(unsigned char *)(0xA0000 + i), 2); Puts4(" ");\r
- i++;\r
- if( (i % 0x10) == 0 ) Puts4("\n");\r
- }\r
- Puts4("\n");\r
-\r
- \r
- /* Output Ready Meassage */\r
- if( global_error != 0 )\r
- {\r
- Puts4("\n********* FLASH Programming Demo failed **********\n");\r
- }\r
- else\r
- {\r
- Puts4("\n********* FLASH Programming Demo done **********\n");\r
- }\r
- \r
- while(1) /* endless loop */\r
- { \r
- \r
- HWWD_CL = 0; \r
- \r
- /* feed hardware watchdog */\r
- /* (Only for devices with hardware (R/C based) watchdog) */\r
- /* The hardware (R/C based) watchdog is started */\r
- /* automatically after power-up and can not be stopped */\r
- /* If the hardware watchdog is not cleared frequently */\r
- /* a reset is generated. */ \r
- } \r
-}\r
-\r
-\r
-/********************@FUNCTION_DECLARATION_END******************/\r
+/* THIS SAMPLE CODE IS PROVIDED AS IS AND IS SUBJECT TO ALTERATIONS. FUJITSU */
+/* MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR */
+/* ELIGIBILITY FOR ANY PURPOSES. */
+/* (C) Fujitsu Microelectronics Europe GmbH */
+/*------------------------------------------------------------------------
+ MAIN.C
+ - description
+ - See README.TXT for project description and disclaimer.
+
+ 06.10.06 1.01 UMa changed includes
+-------------------------------------------------------------------------*/
+
+
+/*************************@INCLUDE_START************************/
+#include "mb91465k.h"
+#include "vectors.h"
+#include "RLT.h"
+#include "Flash.h"
+/**************************@INCLUDE_END*************************/
+
+/*********************@GLOBAL_VARIABLES_START*******************/
+/**********************@GLOBAL_VARIABLES_END********************/
+
+
+/*******************@FUNCTION_DECLARATION_START*****************/
+
+/*********************@FUNCTION_HEADER_START*********************
+*@FUNCTION NAME: main() *
+* *
+*@DESCRIPTION: The main function controls the program flow *
+* *
+*@PARAMETER: none *
+* *
+*@RETURN: none *
+* *
+***********************@FUNCTION_HEADER_END*********************/
+
+
+void main(void)
+{
+ unsigned char error = 0;
+ unsigned char global_error = 0;
+ unsigned int i;
+
+ /* Enable Clock Monitor */
+ CSCFG_MONCKI = 1;
+ CMCFG = 0x0D;
+
+ __EI(); /* enable interrupts */
+ __set_il(31); /* allow all levels */
+ InitIrqLevels(); /* init interrupts */
+
+ PORTEN = 0x3; /* enable I/O Ports */
+ /* This feature is not supported by MB91V460A */
+ /* For all other devices the I/O Ports must be enabled*/
+
+ /* Enable LEDs */
+ DDR27 = 0xFF;
+ PDR27 = 0x00;
+
+ /* Initialize Reload Timer Channel 0 */
+ RLT_InitializeTimer(0, RLT_RUMMODE_RELOAD, RLT_CLOCKMODE_DIV32, RLT_TRIGGER_SOFTWARE, RLT_OUTOUTMODE_HIGHLEVEL);
+ RLT_SetReloadValue(0,0x1388); // CLKP/32, 0.01s Interval => 0x1388 counts
+ RLT_EnableInterrupt(0);
+ RLT_TriggerTimer(0);
+
+ /* Initialize UART4 */
+ InitUart4();
+
+ /* Output Welcome Message */
+ Puts4(" \n\n");
+ Puts4("\n\n********** Welcome to FUJITSU FLASH Programming Demo **********\n");
+
+ /* Do BlankCheck on Sector at 0xA0000 */
+ Puts4("Blank Check of FLASH Sector at 0xA0000 ... ");
+ error = FLASH_SectorBlankCheck(0xA0000, 0x4000);
+ if( error == 1 )
+ {
+ Puts4("done.\n");
+ }
+ else
+ {
+ Puts4("failed.\n");
+ }
+
+ /* Show Current Content of 0xA0000 ... 0xA001F */
+ i=0;
+ Puts4("\nCurrent Content of FLASH at 0xA0000 ... 0xA001F:\n");
+ while(i < 0x20)
+ {
+ Puts4("0x"); Puthex4( *(unsigned char *)(0xA0000 + i), 2); Puts4(" ");
+ i++;
+ if( (i % 0x10) == 0 ) Puts4("\n");
+ }
+ Puts4("\n");
+
+ /* SectorErase of FLASH Memory 0xA0000*/
+ Puts4("Sector Erase of 0xA0000 ... ");
+ error = FLASH_SectorErase(0xA0000);
+ error = FLASH_SectorErase(0xA0004);
+ if( error == 1 )
+ {
+ Puts4("done.\n");
+ }
+ else
+ {
+ global_error = 1;
+ Puts4("failed.\n");
+ }
+
+ /* Do BlankCheck on Sectors at 0xA0000 */
+ Puts4("Blank Check of FLASH Sector at 0xA0000 ... ");
+ error = FLASH_SectorBlankCheck(0xA0000, 0x4000);
+ if( error == 1 )
+ {
+ Puts4("done.\n");
+ }
+ else
+ {
+ global_error = 1;
+ Puts4("failed.\n");
+ }
+
+ /* Show Current Content of 0xA0000 ... 0xA001F */
+ i=0;
+ Puts4("\nCurrent Content of FLASH at 0xA0000 ... 0xA001F:\n");
+ while(i < 0x20)
+ {
+ Puts4("0x"); Puthex4( *(unsigned char *)(0xA0000 + i), 2); Puts4(" ");
+ i++;
+ if( (i % 0x10) == 0 ) Puts4("\n");
+ }
+ Puts4("\n");
+
+ /* Write 0x55AA to 0xA0002 */
+ Puts4("Write 0x55AA to 0xA0002 ... ");
+ error = FLASH_WriteHalfWord(0xA0002,0x55AA);
+ if( error == 1 )
+ {
+ Puts4("done.\n");
+ }
+ else
+ {
+ global_error = 1;
+ Puts4("failed.\n");
+ }
+
+ /* Write 0x33CC to 0xA0004 */
+ Puts4("Write 0x33CC to 0xA0004 ... ");
+ error = FLASH_WriteHalfWord(0xA0004,0x33CC);
+ if( error == 1 )
+ {
+ Puts4("done.\n");
+ }
+ else
+ {
+ global_error = 1;
+ Puts4("failed.\n");
+ }
+
+ /* Show Current Content of 0xA0000 ... 0xA001F */
+ i=0;
+ Puts4("\nCurrent Content of FLASH at 0xA0000 ... 0xA001F:\n");
+ while(i < 0x20)
+ {
+ Puts4("0x"); Puthex4( *(unsigned char *)(0xA0000 + i), 2); Puts4(" ");
+ i++;
+ if( (i % 0x10) == 0 ) Puts4("\n");
+ }
+ Puts4("\n");
+
+
+ /* Output Ready Meassage */
+ if( global_error != 0 )
+ {
+ Puts4("\n********* FLASH Programming Demo failed **********\n");
+ }
+ else
+ {
+ Puts4("\n********* FLASH Programming Demo done **********\n");
+ }
+
+ while(1) /* endless loop */
+ {
+
+ HWWD_CL = 0;
+
+ /* feed hardware watchdog */
+ /* (Only for devices with hardware (R/C based) watchdog) */
+ /* The hardware (R/C based) watchdog is started */
+ /* automatically after power-up and can not be stopped */
+ /* If the hardware watchdog is not cleared frequently */
+ /* a reset is generated. */
+ }
+}
+
+
+/********************@FUNCTION_DECLARATION_END******************/