Other Parts Discussed in Thread: CC1310
Hello.
I am trying to control a 1Gb NAND Flash memory model w25n01gv from Winbond (using the Mikroe Flash 5 Click board: www.mikroe.com/flash-5-click) through the SPI driver of a CC1310 LaunchPAD.
Before going on building all the I/O API, I have just written a pair of basic functions to test the communication with the memory: read the JEDEC ID and read one of the three status registers.
Looking for the correct setting of the CC1310 SPI frame format I searched the memory datasheet (www.winbond.com/.../W25N01GV Rev O 092619.pdf) and took this information:
- SPI frame of 8 bits
- /CS pin has to be LOW during all the memory command (during all the SPI transaction)
- Input: memory reads bit data from master in rising edges of clock
- Output: memory prepares bit data after falling edges of clock and can be read from master in rising edges of clock
- Memory accepts clock signal normally LOW or normally HIGH during bus standby times
Reading the CC1310 reference manual about the SPI modes I saw that the /CS line is only held LOW during a complete SPI transaction when using Phase-Control=1, so I started the tests using SPI0 with 1MHz, frame format set to SPI_POL0_PHA1 and defining the CC1310_LAUNCHXL_SPI0_CSN in the PIN_Config BoardGpioInitTable[]. It didn't work.
To see what was happening I connected an oscilloscope to /CS (red signal), CLK (yellow signal), MISO (magenta signal) and MOSI (green signal) pins. This is what I saw when reading a status register (Byte 0: command, Byte 1: register address, Byte 2: register value returned):
<SR1 - CS SPI0 - POL0_PHA1 - 1MHz - SPI0>
As you can see the /CS pin goes up between SPI frames and nothing came out from the memory. To discard a misname of the mode, I changed to SPI_POL0_PHA0, and this is what I got:
<SR1 - CS SPI0 - POL0_PHA0 - 1MHz - SPI0>
Except a clock/2 delay for the active edge of the clock, everything was the same. No difference in the /CS pin between the SPI_POL0_PHA1 and SPI_POL0_PHA0 modes. I checked SPI_POL1_PHA1 and SPI_POL1_PHA0: the clock pin in idle times was HIGH as expected, but /CS line went up between SPI frames in all cases.
To try to solve the situation I defined a GPIO pin for manual control of /CS line and checked with SPI_POL0_PHA1:
<SR1 - CS GPIO - POL0_PHA1- 1MHz - SPI0>
Now I had /CS LOW during all the transaction but no output from the memory yet.
I changed the test from reading the status register to reading the Jedec ID (Byte 0: command, Byte 1: dummy, Byte 2: manufacturer ID returned, Byte 3-4: device ID returned):
<Jedec - CS GPIO - POL0_PHA1- 1MHz - SPI0>
Same as the register test: not working.
Then I remembered that the memory use rising edges for input and output bit data and if I was manually controlling de /CS line with a external pin, I didn't need the PHA set to 1 (moreover if it didn't work as expected). So I tried with SPI_POL0_PHA0:
<Jedec - CS GPIO - POL0_PHA0- 1MHz - SPI0>
Finally I got an output from the memory!... but not the correct one: I got a manufacturer ID of 0xDC instead of the expected 0xEF. And nothing for the device ID: 0x0000 instead of the expected 0xAA21.
I also saw big instant pulses in the MISO line. Possibly due to the cables I am using to connect the memory to the CC1310 LaunchPAD. Thinking on this and knowing that the LaunchPAD has another memory connected to the SPI0, I tried again all the same tests with the SPI1. Everything worked the same way as with the SPI0. And the POLxPHA1 problem exists in both SPI0 and SPI1.
Then I realized that the 0xDC I was getting in the last test, would be a 0xEF if the clock train was continuous and not having the gaps it has between the SPI frames.
Taking into account all the results of the tests I have the next questions:
1. Why the /CS pin is going HIGH after each frame in the POLxPHA1 modes when the reference manual of CC1310 says it will keep LOW during all the SPI transaction? Any way it can works as in the specification?
2. Why is it associated the /CS (SSIn_FSS) behaviour with the Phase-control? Isn't it more interesting and compatible with more devices to separate the roles and that we can set in the SPI parameters the Polarity and Phase on the one hand and a new parameter like "SSIn_FSS continuous transfer" on the other hand where we can choose between single frame /CS or continuous frame /CS? This would avoid the need to implement an external GPIO dedicated to control /CS and avoid the lags associated to GPIO signals.
3. Why are there those clock stops between frames? Shouldn't it be a continuous train of pulses from the beginning of the transaction to the end? I suppose it is related to the /CS control behaviour made in the SPI driver. When in PHA=0 the /CS must go HIGH between frames, so the clock must stop at those moments. On the other hand when in PHA=1 /CS should be held LOW and the clock could be continuous... but as I showed you before this mode is not working properly. And even working as intended, It will not work for me as the memory needs rising edges of clocks to input and output data. Another reason to consider the implementation of a separate SPI parameter to control /CS as I have said in previous point 2. How can I get a continuous train of clock pulses with active rising edges to make the memory work?
And I have some questions about the pin configuration of the SPI driver:
4. Why all the SPI pin are defined in the PIN driver "PIN_Config BoardGpioInitTable[]" array as PULLDOWN inputs? Shouldn't CLK and MOSI be defined as outputs?
5. To disable the /CS SPI pin I have seen I need to define CC1310_LAUNCHXL_SPI0_CSN as PIN_UNASSIGNED. This prevents propagating the signal into a pin. Nevertheless if I define the CC1310_LAUNCHXL_SPI0_CSN to a pin and I don't include this pin configuration in the "PIN_Config BoardGpioInitTable[]" array, I have seen this pin has the /CS signal. How could it be? Is it the pin defined at runtime inside the SPI driver and we don't need to configure it statically in the pin array?
Regards,
Juan Pablo Novo