Manage 3 SPI device with MQX3.4

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

Manage 3 SPI device with MQX3.4

1,407 次查看
elel
Contributor III

Hello,

I'm using MCF52259 with the MQX3.4.


In my  application there are 3 SPI devices which are connected to MCF52259, and each device has its own chip select pin(QSPI_CS0, QSPI_CS2, QSPI_CS3).


Now I've created an ISR where,for each device, I put the data in a buffer, I set the correct chip select, and then start the communication with the SPI.


This method it's working good, but I think I can increase the performance doing only one comunication.


So my question is: can I set a queue of data that are send on different chip select automatically by the SPI?

 

Thanks in advice

 

Stefano

 

0 项奖励
3 回复数

276 次查看
PetrM
Senior Contributor I

Hello,

 

if you are using SPI driver, it's possible to write any number of data to one device at once. Just setup correct chip select using ioctl command and call fwrite (buffer, 1, count, spi_fd).

 

If you're just accessing QSPI registers, there is also HW queue of 16 bytes, that can be filled to transfer data to same chip select/device at once. And you get interrrupt request after the whole queue is sent.

 

But there is no automatic data send, you have to fill the buffers before each transmission.

 

PetrM

0 项奖励

276 次查看
kecart
Contributor III

I am also trying to get an application functioning that has multiple SPI devices.  I am using the MQX 3.5 SPI drivers on an m52259evb and I am seeing a problem in the _mcf5xxx_qspi_polled_tx_rx function.  The initiate transmission works as expected.  All queued bytes are transferred with the correct chip select active low.  Setting a breakpoint on the write to QWR confirms that all chip selects are inactive at the end of the transfer.  Stepping through the write to QWR shows that ALL chip selects are changed to the low state instead of only the selected chip select.

 /* Initiate transmission */
 qspi_ptr->QDLYR |= MCF5XXX_QSPI_QDLYR_SPE;

 /* CS inactive low for tranfers longer than 16 words */
 qspi_ptr->QWR &= (~ MCF5XXX_QSPI_QWR_CSIV);

How do I get ONLY the chip select for this device to go active low at the beginning of the transmission and stay low when the transmission is complete without making the chip selects GPIO?

Petr, you have my email address and phone number if you want to discuss this in detail.

 

 

0 项奖励

277 次查看
PetrM
Senior Contributor I

Hello,

 

during one transfer, only those chip selects you previously stated with IO_IOCTL_SPI_SET_CS are driven low.

After one transfer within that function, chip select needs to stay low not to interrupt the overal transmission.

However, because of HW constraint, all chip selects can be held simultaneously low only. That's what you saw.

Sorry, but there's really no other way, except the GPIO chip select callback.

 

PetrM

 

0 项奖励