SPI communication between two ADuCM3029

Hi,

I'm trying to communicate between two ADuCM3029, one as master and another as a slave.

I can send data from master to the spi bus and everything works fine. 

In the slave side, I want to generate an interruption every time I receive a new data with 16 bits size.

I can generate an interruption using this function adi_spi_SlaveReadWrite from DFP, but this way I need to polling the call of this function.

I tried this *pREG_SPI0_IEN = BITM_SPI_IEN_CS without calling the DFP function, I got zero interruptions.

Is it possible to generate SPI interruptions without using DFP functions?

Parents
  • Hello,

    Yes it is possible to generate SPI interrupts without using DFP and it is also possible to use the DFP functions to achieve what you need.

    The reason the CS interrupt might not have worked is because this interrupt only works in continuous mode and if it is a slave. Maybe the continuous mode is not active.

    You can get interrupts on receive after two bytes if you follow the instructions described on page 338 of 690 of this document. Basically the SPI_CTL register must have its TIM bit cleared, the SPI_IEN register must have the IRQMODE bits set to 1 and the SPI_CTL register must have its RFLUSH bit cleared. This way an interrupt is generated every time two bytes are received in the FIFO.

    I would like to frame-challenge the question and suggest you use the DFP drivers. In the installation folder for the DFP pack in the 'Documents' folder there is the file ADuCM302x_DFP_Device_Drivers_UsersGuide.pdf. This guide explains better how to use the APIs for the DFP drivers. Basically there are three modes of operation: blocking calls, non-blocking calls and callback calls. All use interrupts, but as you have seen, the adi_spi_SlaveReadWrite is a blocking call and only returns when the bytes are received.

    To have a non-blocking call you can use adi_spi_SlaveSubmitBuffer if you have specific points in the code where you check for received bytes. After calling this function it is safe to do other stuff and then check if the buffer is available with adi_spi_isBufferAvailable. If this returns true you can get the received data by using adi_spi_GetBuffer.

    A callback can be used if you want to process the data the moment it arrives. You can write a function with the ADI_CALLBACK type and pass its pointer to the adi_spi_RegisterCallback. Then, when the callback is reached, the pointer to the filled buffer will be pArg. Just make sure to not use the callback and non-blocking calls together.

    Regards,

    Andrei.

Reply
  • Hello,

    Yes it is possible to generate SPI interrupts without using DFP and it is also possible to use the DFP functions to achieve what you need.

    The reason the CS interrupt might not have worked is because this interrupt only works in continuous mode and if it is a slave. Maybe the continuous mode is not active.

    You can get interrupts on receive after two bytes if you follow the instructions described on page 338 of 690 of this document. Basically the SPI_CTL register must have its TIM bit cleared, the SPI_IEN register must have the IRQMODE bits set to 1 and the SPI_CTL register must have its RFLUSH bit cleared. This way an interrupt is generated every time two bytes are received in the FIFO.

    I would like to frame-challenge the question and suggest you use the DFP drivers. In the installation folder for the DFP pack in the 'Documents' folder there is the file ADuCM302x_DFP_Device_Drivers_UsersGuide.pdf. This guide explains better how to use the APIs for the DFP drivers. Basically there are three modes of operation: blocking calls, non-blocking calls and callback calls. All use interrupts, but as you have seen, the adi_spi_SlaveReadWrite is a blocking call and only returns when the bytes are received.

    To have a non-blocking call you can use adi_spi_SlaveSubmitBuffer if you have specific points in the code where you check for received bytes. After calling this function it is safe to do other stuff and then check if the buffer is available with adi_spi_isBufferAvailable. If this returns true you can get the received data by using adi_spi_GetBuffer.

    A callback can be used if you want to process the data the moment it arrives. You can write a function with the ADI_CALLBACK type and pass its pointer to the adi_spi_RegisterCallback. Then, when the callback is reached, the pointer to the filled buffer will be pArg. Just make sure to not use the callback and non-blocking calls together.

    Regards,

    Andrei.

Children