LPC55x wrong number of pulse clock in SPI peripheral

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

LPC55x wrong number of pulse clock in SPI peripheral

2,537 次查看
Marconi_
Contributor I

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

Marconi__0-1714310564024.png

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.

 

Marconi__1-1714311801815.png

 

0 项奖励
回复
5 回复数

2,509 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @Marconi_ 

It seems this issue related your another thread. How about also first using the SPI demo under SDK to test? 

Please contact us if still have any issue.

 

BR

Alice

0 项奖励
回复

2,503 次查看
Marconi_
Contributor I

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

0 项奖励
回复

2,430 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @Marconi_ 

You can also use a gpio control slave selection.

 

BR

Alice

0 项奖励
回复

2,381 次查看
Marconi_
Contributor I

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

 

0 项奖励
回复

1,844 次查看
Marconi_
Contributor I

Dear all,

I analyzed th code and I found a bug in SPI_WriteData routine that I fixed.

regards

 

0 项奖励
回复