8 unsigned char error = 0;
9 unsigned char global_error = 0;
10 unsigned int i, baseaddr;
12 /* Enable Clock Monitor */
16 __EI(); /* enable interrupts */
17 __set_il(31); /* allow all levels */
18 InitIrqLevels(); /* init interrupts */
20 PORTEN = 0x3; /* enable I/O Ports */
21 /* This feature is not supported by MB91V460A */
22 /* For all other devices the I/O Ports must be enabled*/
28 /* Initialize Reload Timer Channel 0 */
29 RLT_InitializeTimer(0, RLT_RUMMODE_RELOAD, RLT_CLOCKMODE_DIV32, RLT_TRIGGER_SOFTWARE, RLT_OUTOUTMODE_HIGHLEVEL);
30 RLT_SetReloadValue(0,0xfffe);
32 RLT_EnableInterrupt(0, 1);
34 /* Initialize UART4 */
37 /* Output Welcome Message */
39 Puts4("\n\n********** Welcome to FUJITSU FLASH Programming Demo **********\n");
43 for (; i <0x30; i+=4) {
44 error = FLASH_SectorErase(baseaddr + i);
46 Puts4(error == 1 ? "[success] " : "[failed] ");
47 Puthex4(baseaddr + i, 6);
50 Puts4("Write simpleprog to 0xf4000 ... ");
51 error = FLASH_WriteHalfWord(0xf4000,0x9b00);
52 error = FLASH_WriteHalfWord(0xf4002,0x0d4e);
53 error = FLASH_WriteHalfWord(0xf4004,0xcff1);
54 error = FLASH_WriteHalfWord(0xf4006,0x1601);
55 error = FLASH_WriteHalfWord(0xf4008,0x9b05);
56 error = FLASH_WriteHalfWord(0xf4010,0x04c7);
57 error = FLASH_WriteHalfWord(0xf4012,0xc106);
58 error = FLASH_WriteHalfWord(0xf4014,0x1656);
59 error = FLASH_WriteHalfWord(0xf4016,0xe0fb);
71 Puts4("\nCurrent Content of FLASH at 0xf4000 ... 0xf401F:\n");
74 Puts4("0x"); Puthex4( *(unsigned char *)(0xf4000 + i), 2); Puts4(" ");
76 if( (i % 0x10) == 0 ) Puts4("\n");
81 /* Output Ready Meassage */
82 if( global_error != 0 )
84 Puts4("\n********* FLASH Programming Demo failed **********\n");
88 Puts4("\n********* FLASH Programming Demo done **********\n");
91 RLT_EnableInterrupt(0, 0);