Running SPI's concurrently on the MPC5744P with S32DS

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

Running SPI's concurrently on the MPC5744P with S32DS

1,707 次查看
pierre_theron
Contributor III

Hi.

I have 2 SPI's: SPI3 and SPI4 configured in Master mode with interrupts talking to 2 different slave devices. When I initiate an SPI transfer of SPI3, and thereafter an SPI transfer of SPI4, I get the correct data on SPI3, but the data on SPI4 is not correct. If I change it around to initiate SPI transfer on SPI4 first followed by SPI3, I get correct data on SPI4, but the data on SPI3 is not correct. I tried to change interrupt priorities on both SPI3 and SPI4, but that did not make any difference.

I decode the received data in the receive callback functions, and there the data of the second SPI is always 0xFF.

To me it looks like the MPC5744P cannot do more than 1 SPI transaction at the same time? Can you please verify if this is the case.

In another section of my Software I have a different SPI: SPI1, if I increase the data size of this SPI, it also stops working. This happens when this SPI transaction starts to overlap with another SPI. This SPI works with DMA and have a lower priority compared to SPI3 and SPI4.

I also cannot run SPI3 and SPI4 with DMA, because the driver function for initiating a transfer takes too long. I have to read the devices connected to SPI3 and SPI4 at a rate of 7.2kHz which is not possible if I use DMA.

Herewith part of my code in the main loop:

DSPI_MasterTransfer(INST_DSPI3, TxDummyData, SPI3Data, 6);

....

DSPI_MasterTransfer(INST_DSPI4, TxDummyData2, SPI4Data, 6);

The callback functions:

void RX_SPI3Data(void *driverState, spi_event_t event, void *userData)
{
  ReadResolverSPI3(&FOC_Azimuth);
}

void RX_SPI4Data(void *driverState, spi_event_t event, void *userData)
{
  ReadResolverSPI4(&FOC_Elevation);
}

The ReadResolver functions decode SPI3Data and SPI4Data respectively and populate the datastructures.

To summarise, my basic question is, can the MPC5744P transmit more than 1 SPI at the same time? To me it looks like it is not possible.

Regards,

Pierre

标签 (1)
0 项奖励
回复
4 回复数

1,593 次查看
pierre_theron
Contributor III

Hi Razvan

In our hardware we have 2 slave devices per SPI channel. We did not use CS on the devices as the slave devices that we are reading do not have a chip select input. To multiplex 2 devices per SPI we have two clock enable lines that are discreet outputs from the NXP. We AND the specific clock enable line with the clock output to clock the specific SPI slave device that we want to read from. We AND the first clock enable line with the clock outputs of SPI3 and SPI4 to select the first two SPI slave devices connected to SPI3 and SPI4. We AND the second clock enable line to select the

second SPI slave devices connected  to SPI3 and SPI4. What happened is the clock enable line was disabled in the first callback function that caused the second SPI read to fail. If we swopped the order of reading around, the second SPI was failing again as a result of the clock begin disabled after the first callback was received. By disabling the clock only in the second callback function we are now reading both SPI slave devices correct.

In other words, the problem was on our side with our software not setup according to our hardware configuration.

Previously we were not reading SPI3 and SPI4 concurrently, and disabling the clock in the first callback did not disable the clock read for the following SPI. Before initiating an SPI transfer, we Enable the clock line for the selected slave device.

The statement I made: "To me it looks like the MPC5744P cannot do more than 1 SPI transaction at the same time?" is thus wrong as we are now reading both devices concurrently and receiving the correct data.

Thanks a lot for your effort in trying to reproduce the problem we had. We can now at least say with confidence that SPI's can run at the same time without any problems.

Regards,

Pierre

0 项奖励
回复

1,592 次查看
razva_tilimpea
NXP Employee
NXP Employee

Hi,

Thanks for update. I'm please to head that you can continue your development without issues from our software.

Best regards,

Razvan

0 项奖励
回复

1,592 次查看
razva_tilimpea
NXP Employee
NXP Employee

Hi,

Could you share your project with us? We weren't able to reproduce it.

Best regards,

Razvan

0 项奖励
回复

1,592 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi Pierre,

just to inform you - this is being checked by SDK team. They will share the findings later.

Regards,

Lukas

0 项奖励
回复