??? 06/15/04 09:43 Read: times |
#72516 - RE: Parallel to SPI interface Converter IC Responding to: ???'s previous message |
Hi!
Well, you asked the question I have done some days ago exactly. My new project requires SPI flash memory, here: Atmel`s DataFlash(R). For some reasons I may not use a part with built-in SPI controller (like RD2,ID2 etc). And so what I have started from: - MCU: T89C51CC01 (clocked with 18.432MHz; x2 mode is utilized); - SPI: AT45DB041B (4Mbit SPI flash memory; 20MHz clock frequency max.); - CPLD: Altera EPM7128STC100. First of all, I have drop the idea of "software SPI" because I need very fast access while read the flash and so if software emulation be used, it decreases MCU productivity with all these bits` manipulations. So, the firsts story is started. I have created SPI module inside CPLD. It is really easy because needs only one 8-bit shift register and a little framework about its maintenance: ![]() To access SPI by such way, I just do MOVX with 15-clock /RD/WR stretch. It produces ~800ns duration of /WR and /RD signals. Inside this time, shift register is loaded (if I write to memory via MOVX), shifted 8 times to left (~450ns) and read back (if I read from memory via MOVX). This works perfect. The end of the first story. But... Looking on the timings of the SPI mode 3 (which is default mode for that flash memory), I remembered that I have already seen similar figure somewhere. So I set down and thought. And I got it! It is the shift register of UART in the mode 0 !!! Okay, then I reconfigured CPLD and utilized just UART: TX as SPI clock and RX as bi-directiolal SI+SO line. Simple test program, power-on... it works! I do MOV SBUF,#xx and it sends byte to flash memory! I do CLR RI then SETB REN and it receives a byte from flash memory! Well, I did it for test purposes, because I will use MOVX (first story). Anyway, the simplest SPI is just UART mode 0. If you plane to use such way, just some more notes: - generally, SPI uses format "MSB first" while UART uses "LSB first". So you must rearrange bits (for send you may use just a macro; for receive - simple subroutine); - UART in mode 0 uses fixed clock ratio (OSC/12 or OSC/6 in x2 mode). So you need to check SPI and UART timings for that they are compatible. If they are not then there is no way to fix this problem :( Regards, Oleg |
Topic | Author | Date |
Parallel to SPI interface Converter IC | 01/01/70 00:00 | |
RE: Parallel to SPI interface Converter | 01/01/70 00:00 | |
RE: Parallel to SPI interface Converter | 01/01/70 00:00 | |
RE: Parallel to SPI interface Converter | 01/01/70 00:00 | |
RE: Parallel to SPI interface Converter | 01/01/70 00:00 | |
RE: Parallel to SPI interface Converter | 01/01/70 00:00 | |
RE: Parallel to SPI interface Converter IC | 01/01/70 00:00 | |
RE: Parallel to SPI interface Converter IC | 01/01/70 00:00 | |
RE: Parallel to SPI interface Converter IC | 01/01/70 00:00 | |
RE: Parallel to SPI interface Converter IC![]() | 01/01/70 00:00 |