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