1 /* THIS SAMPLE CODE IS PROVIDED AS IS AND IS SUBJECT TO ALTERATIONS. FUJITSU */
2 /* MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR */
3 /* ELIGIBILITY FOR ANY PURPOSES. */
4 /* (C) Fujitsu Microelectronics Europe GmbH */
5 /*------------------------------------------------------------------------
8 - See README.TXT for project description and disclaimer.
10 06.10.06 1.01 UMa changed includes
11 -------------------------------------------------------------------------*/
14 /*************************@INCLUDE_START************************/
19 /**************************@INCLUDE_END*************************/
21 /*********************@GLOBAL_VARIABLES_START*******************/
22 /**********************@GLOBAL_VARIABLES_END********************/
25 /*******************@FUNCTION_DECLARATION_START*****************/
27 /*********************@FUNCTION_HEADER_START*********************
28 *@FUNCTION NAME: main() *
30 *@DESCRIPTION: The main function controls the program flow *
36 ***********************@FUNCTION_HEADER_END*********************/
41 unsigned char error = 0;
42 unsigned char global_error = 0;
45 /* Enable Clock Monitor */
49 __EI(); /* enable interrupts */
50 __set_il(31); /* allow all levels */
51 InitIrqLevels(); /* init interrupts */
53 PORTEN = 0x3; /* enable I/O Ports */
54 /* This feature is not supported by MB91V460A */
55 /* For all other devices the I/O Ports must be enabled*/
61 /* Initialize Reload Timer Channel 0 */
62 RLT_InitializeTimer(0, RLT_RUMMODE_RELOAD, RLT_CLOCKMODE_DIV32, RLT_TRIGGER_SOFTWARE, RLT_OUTOUTMODE_HIGHLEVEL);
63 RLT_SetReloadValue(0,0xfffe);
65 RLT_EnableInterrupt(0, 1);
67 /* Initialize UART4 */
70 /* Output Welcome Message */
72 Puts4("\n\n********** Welcome to FUJITSU FLASH Programming Demo **********\n");
74 /* Do BlankCheck on Sector at 0xA0000 */
75 Puts4("Blank Check of FLASH Sector at 0xA0000 ... ");
76 error = FLASH_SectorBlankCheck(0xA0000, 0x4000);
86 /* Show Current Content of 0xA0000 ... 0xA001F */
88 Puts4("\nCurrent Content of FLASH at 0xA0000 ... 0xA001F:\n");
91 Puts4("0x"); Puthex4( *(unsigned char *)(0xA0000 + i), 2); Puts4(" ");
93 if( (i % 0x10) == 0 ) Puts4("\n");
97 /* SectorErase of FLASH Memory 0xA0000*/
98 Puts4("Sector Erase of 0xA0000 ... ");
99 error = FLASH_SectorErase(0xA0000);
100 error = FLASH_SectorErase(0xA0004);
111 /* Do BlankCheck on Sectors at 0xA0000 */
112 Puts4("Blank Check of FLASH Sector at 0xA0000 ... ");
113 error = FLASH_SectorBlankCheck(0xA0000, 0x4000);
124 /* Show Current Content of 0xA0000 ... 0xA001F */
126 Puts4("\nCurrent Content of FLASH at 0xA0000 ... 0xA001F:\n");
129 Puts4("0x"); Puthex4( *(unsigned char *)(0xA0000 + i), 2); Puts4(" ");
131 if( (i % 0x10) == 0 ) Puts4("\n");
135 /* Write 0x55AA to 0xA0002 */
136 Puts4("Write 0x55AA to 0xA0002 ... ");
137 error = FLASH_WriteHalfWord(0xA0002,0x55AA);
148 /* Write 0x33CC to 0xA0004 */
149 Puts4("Write 0x33CC to 0xA0004 ... ");
150 error = FLASH_WriteHalfWord(0xA0004,0x33CC);
161 /* Show Current Content of 0xA0000 ... 0xA001F */
163 Puts4("\nCurrent Content of FLASH at 0xA0000 ... 0xA001F:\n");
166 Puts4("0x"); Puthex4( *(unsigned char *)(0xA0000 + i), 2); Puts4(" ");
168 if( (i % 0x10) == 0 ) Puts4("\n");
173 /* Output Ready Meassage */
174 if( global_error != 0 )
176 Puts4("\n********* FLASH Programming Demo failed **********\n");
180 Puts4("\n********* FLASH Programming Demo done **********\n");
183 RLT_EnableInterrupt(0, 0);
185 while(1) /* endless loop */
190 /* feed hardware watchdog */
191 /* (Only for devices with hardware (R/C based) watchdog) */
192 /* The hardware (R/C based) watchdog is started */
193 /* automatically after power-up and can not be stopped */
194 /* If the hardware watchdog is not cleared frequently */
195 /* a reset is generated. */
200 /********************@FUNCTION_DECLARATION_END******************/