Dear all,
Using LPCXPresso55S28 board I try to send 16 bit data via SPI. I'm using FLEXCOMM2 and I connected my locical analyzer to the board using the pins:
- P18 [15] -> MOSI
- P18 [18] -> SSEL0
- P18[8] -> SCK
Using MCUXpressoIDE peripherals configurator I configured FLEXCOMM2 as shown in the picture
I wrote a very simple program to test SPI functionality.
The program iterates 20 times using a loop. Inside the loop, a variable 'dato' is incremented by one in each iteration. This variable likely holds the data I want to send over SPI and the function called SPI_WreiteData is called to send information via SPI. Then a funcion called SPI_ReadData is called to read 'fummy' data from SPI.
SPI_WriteData(FLEXCOMM2_PERIPHERAL, dato, kSPI_FrameDelay | kSPI_FrameAssert);
xxy = SPI_ReadData(FLEXCOMM2_PERIPHERAL);
(xxy is a volatile uint32_t variable)
Unfortunately after the last frame is transmitted the CS signal remains low. The number of pulse clock of the last frame is wromg (15 pulses instead of 16 pulses)
In the following picture the captured signal of the two last frames are shown. You can observe only 15 clock pulses for the last frame instead of the expected 16.
Dear @Alice_Yang
you wrte:
> It seems this issue related your another thread
Yes, the post is related to my previouse post.
I partially fixed the problem adding the function SPI_ReadData but:
- The last frame has the wrong number of clock pulses. In SPI communication, data is transferred with clock pulses, so an incorrect number might corrupt the data.
- The chip select signal, which is used to activate/deactivate the slave device, doesn't return to a high state after the transmission. This could indicate the slave device isn't releasing properly.
regards
Dear @Alice_Yang
Thank you for your answer
you wrote:
>You can also use a gpio control slave selection.
The Serial Peripheral Interface (SPI) typically facilitates data conversion from parallel to serial format. However, I've encountered some potential issues with the SPI implementation on my LPC552x microcontroller.
Could you help verify if this is true? If not, perhaps you could provide a code routine demonstrating how to transmit data using the LPC552x SPI interface using SPI_WriteData routine ?
Thank you for your help and cooperation
regards