Hi, I am facing a problem while reading and writing to External Flash memory. In the hardware we are using, C167-CS microcontroller is interfaced to external FLASH (M29F200). These are the interface connections: /CS0 of the microcontroller is connected to /OE of the FLASH /CS3 of the microcontroller is connected to /WR of the FLASH The chip enable(/E) of the FLASH is permanently grounded. In the software, BUSCON0 has been configured for read. BUSCON3 has been configured for write. ADDRSEL3 has been mapped to 256KB starting from address 0x80000. I am able to write to the FLASH but unable to read. What has to be done to read and write into the FLASH? Please help me out. Thanks & Regards, Rajendra
What addresses do you read from? You can't read from 0x80000-0xBFFFF, because those reads wouldn't activate OE. BUSCON0 is for memory range not occupied by any of the BUSCON1..BUSCON4. -mike
Mike, I have only one FLASH. All the FLASH read & write operations should be performed for the address range 0x80000 - 0xBFFFF. -Rajendra
With the connections that you have: /CS0 of the microcontroller is connected to /OE of the FLASH /CS3 of the microcontroller is connected to /WR of the FLASH you will not be able to read from and write to the flash chip through the same memory window. It's a hardware limitation. If you don't like that, change the wiring. Usually this sort of limitation is not a big deal: the C167 architecture has plenty of address space, hence it's OK to have two nonoverlapping memory windows for read and write. - mike
Mike, The same settings are working fine in BSL (bootstrap loader)mode. We are able to setup CAN messaging and program(read/write) the external flash in BSL mode. I have not changed any hardware settings and retained the same BUSCON0 & BUSBON3, ADDRSEL3 settings as mentioned in the previous mail while working in the BSL mode. This type of external flash access is suggested in the "166 Family Designer's Guide" from Hitex. Looks like this will work only in BSL mode as system reset does not come into picture in this method. Is my assumption valid ? Thanks & Regards, Rajendra
Hi Rajendra. This type of external flash access is suggested in the "166 Family Designer's Guide" from Hitex. I read that book too. The only reason why you would want to use this sort or connection to external memory is to avoid the 20 ns delay in the internal address decoding logic between address window activation and CSx falling edge. The "standard" connection is CSx to CE, RD to RD, WR to WR. If your memory IC is fast enough, I would suggest the standard connection, because this way you get read and write access through the same address window. If flash is the only peripheral connected to the external bus, then you can save yourself the hassle and connect RD to RD, WR to WR, leave CSx's unconnected and CE tied to ground. Looks like this will work only in BSL mode as system reset does not come into picture in this method. Is my assumption valid ? To the best of my knowledge, no. If it works in BSL mode, it should work in normal mode as well. There are differences between those modes, but I can't see how they can create this problem. But I don't know the exact configuration of your target hardware, of course. If you have to use this sort of connection to external memory to avoid additional waitstates, you have to keep in mind that from the programmer's standpoint read and write accesses will be through different address windows. Once again, (M29F200). These are the interface connections: /CS0 of the microcontroller is connected to /OE of the FLASH /CS3 of the microcontroller is connected to /WR of the FLASH The chip enable(/E) of the FLASH is permanently grounded. In the software, BUSCON0 has been configured for read. BUSCON3 has been configured for write. ADDRSEL3 has been mapped to 256KB starting from address 0x80000. This configuration means that you write to flash through addresses 0x80000-0xBFFFF. Read attempts from those addresses will be ignored. You can still read from flash, but through different addresses. The same settings are working fine in BSL If you mean that with those settings you can read from flash through addresses 0x80000-0xBFFFF, I can't see how it's possible. Regards, - mike