8 unsigned char error = 0;
9 unsigned char global_error = 0;
10 unsigned int i, baseaddr;
11 unsigned int toflash[] = {0x9b00,
21 /* Enable Clock Monitor */
25 __EI(); /* enable interrupts */
26 __set_il(31); /* allow all levels */
27 InitIrqLevels(); /* init interrupts */
29 PORTEN = 0x3; /* enable I/O Ports */
30 /* This feature is not supported by MB91V460A */
31 /* For all other devices the I/O Ports must be enabled*/
37 /* Initialize Reload Timer Channel 0 */
38 RLT_InitializeTimer(0, RLT_RUMMODE_RELOAD, RLT_CLOCKMODE_DIV32, RLT_TRIGGER_SOFTWARE, RLT_OUTOUTMODE_HIGHLEVEL);
39 RLT_SetReloadValue(0,0xfffe);
41 RLT_EnableInterrupt(0, 1);
43 /* Initialize UART4 */
46 /* Output Welcome Message */
48 Puts4("\n\n********** Welcome to FUJITSU FLASH Programming Demo **********\n");
53 for (; i <0x30; i+=4) {
54 error = FLASH_SectorErase(baseaddr + i);
56 Puts4(error == 1 ? "[success] " : "[failed] ");
57 Puthex4(baseaddr + i, 6);
61 Puts4("\nCurrent Content of FLASH at 0xf4000 ... 0xf401F:\n");
64 Puts4("0x"); Puthex4( *(unsigned char *)(0xf4000 + i), 2); Puts4(" ");
66 if( (i % 0x10) == 0 ) Puts4("\n");
75 error = FLASH_WriteHalfWord(baseaddr + (2*i), toflash[i]);
76 Puts4(error == 1 ? "[sucess] " : "[failed] ");
78 Puthex4(toflash[i], 4);
80 Puthex4(baseaddr + (2*i), 6);
84 Puts4("\nCurrent Content of FLASH at 0xf4000 ... 0xf401F:\n");
87 Puts4("0x"); Puthex4( *(unsigned char *)(0xf4000 + i), 2); Puts4(" ");
89 if( (i % 0x10) == 0 ) Puts4("\n");
94 /* Output Ready Meassage */
95 if( global_error != 0 )
97 Puts4("\n********* FLASH Programming Demo failed **********\n");
101 Puts4("\n********* FLASH Programming Demo done **********\n");
104 RLT_EnableInterrupt(0, 0);