6 #pragma section CODE=IRAM,attr=CODE
9 unsigned char error = 0;
10 unsigned char global_error = 0;
11 unsigned int i, baseaddr;
12 unsigned int toflash2[] = {0x9b00,
21 unsigned int toflash[] = {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}; //len = 9
23 /* Enable Clock Monitor */
27 __EI(); /* enable interrupts */
28 __set_il(31); /* allow all levels */
29 InitIrqLevels(); /* init interrupts */
31 PORTEN = 0x3; /* enable I/O Ports */
32 /* This feature is not supported by MB91V460A */
33 /* For all other devices the I/O Ports must be enabled*/
39 /* Initialize Reload Timer Channel 0 */
40 RLT_InitializeTimer(0, RLT_RUMMODE_RELOAD, RLT_CLOCKMODE_DIV32, RLT_TRIGGER_SOFTWARE, RLT_OUTOUTMODE_HIGHLEVEL);
41 RLT_SetReloadValue(0,0xfffe);
43 RLT_EnableInterrupt(0, 1);
45 /* Initialize UART4 */
48 /* Output Welcome Message */
50 Puts4("\n\n********** Welcome to FUJITSU FLASH Programming Demo **********\n");
55 for (; i <0x30; i+=4) {
56 error = FLASH_SectorErase(baseaddr + i);
58 Puts4(error == 1 ? "[success] " : "[failed] ");
59 Puthex4(baseaddr + i, 6);
63 Puts4("\nCurrent Content of FLASH at 0xf4000 ... 0xf401F:\n");
66 Puts4("0x"); Puthex4( *(unsigned char *)(0xf4000 + i), 2); Puts4(" ");
68 if( (i % 0x10) == 0 ) Puts4("\n");
77 error = FLASH_WriteHalfWord(baseaddr + (2*i), toflash[i]);
78 Puts4(error == 1 ? "[sucess] " : "[failed] ");
80 Puthex4(toflash[i], 4);
82 Puthex4(baseaddr + (2*i), 6);
86 Puts4("\nCurrent Content of FLASH at 0xf4000 ... 0xf401F:\n");
89 Puts4("0x"); Puthex4( *(unsigned char *)(0xf4000 + i), 2); Puts4(" ");
91 if( (i % 0x10) == 0 ) Puts4("\n");
93 Puts4("\n================================================================\n");
99 error = FLASH_WriteHalfWord(baseaddr + (2*i), toflash2[i]);
100 Puts4(error == 1 ? "[sucess] " : "[failed] ");
102 Puthex4(toflash2[i], 4);
104 Puthex4(baseaddr + (2*i), 6);
108 Puts4("\nCurrent Content of FLASH at 0xf4000 ... 0xf401F:\n");
111 Puts4("0x"); Puthex4( *(unsigned char *)(0xf4000 + i), 2); Puts4(" ");
113 if( (i % 0x10) == 0 ) Puts4("\n");
116 /* Output Ready Meassage */
117 if( global_error != 0 )
119 Puts4("\n********* FLASH Programming Demo failed **********\n");
123 Puts4("\n********* FLASH Programming Demo done **********\n");
126 RLT_EnableInterrupt(0, 0);