AnsweredAssumed Answered

OnBlockReceived is not called when using SPImaster LDD

Question asked by Brian Herrold on May 1, 2018
Latest reply on May 8, 2018 by Brian Herrold

I am evaluating the Kinetis S9KEAZ128 micro for a design. I am using the FRDM board without modification. I am using KDS v3.2 with Processor Expert to generate code.


When I use the SPImaster_LDD component, I am able to send any amount of SPI data bytes without a problem. I am using interrupts. When I attempt to receive spi data, following the example found in the "help with this component", the OnBlockReceived event never occurs. When I stop execution and look at my data structure, it is always filled with n-1 of the bytes transmitted with the last byte never being populated regardless of the length of data sent.


I am not able to post my full code but a simplified version of it is given below:




   SPI0ptr = SM2_Init(NULL);

    uint16_t Local_SPI_Timeout = 0xFFFF;
    LDD_TError Local_SPI0_Error;


    // Local TX/RX Buffers
    uint8_t LocalTX[4];
    uint8_t LocalRX[4];


    LocalTX[0] = 0x55;
    LocalTX[1] = 0xaa;
    LocalTX[2] = 0xbe;
    LocalTX[3] = 0xef;

    LocalRX[0] = 0;
    LocalRX[1] = 0;
    LocalRX[2] = 0;
    LocalRX[3] = 0;

    // Set the GPIO Bit low as a "manual" CS line.
    GPIOA_PCOR |= 1<<28; 


    Local_SPI0_Error = SM2_ReceiveBlock(SPI0ptr, LocalRX, 4);


    // Send the SPI data
    Local_SPI0_Error = SM2_SendBlock(SPI0ptr , LocalTX, 4);


    // Set the GPIO Bit high as a "manual" CS line.
    GPIOA_PSOR |= 1<<28;

    while (!SPI0_DataReceivedFlag && (Local_SPI_Timeout > 0))





void SM2_OnBlockReceived(LDD_TUserData *UserDataPtr)
    SPI0_DataReceivedFlag = TRUE;

I tie MISO and MOSI together on the FRDM board to test. I would expect the code to execute, OnBlockReceieved to be called, SPI0_DataReceivedFlag to be set to 1, and LocalTX and LocalRX to be equal.


What happens is that OnBlockReceieved is never called (breakpoint never reached), SPI0_DataReceivedFlag remains zero, and LocalRX[0] = 55, LocalRX[1] = aa, LocalRX[2] = be, LocalRX[3] = 00. I have verified with a scope that the 4 TX bytes are being transmitted correctly with  the clocks and CS. This pattern occurs for any length of data. If I set the TX and RX size to 10, 10 bytes will send successfully (verified by scope) and the LocalRX array will be filled with the first 9 and the 10th still set to zero.


I would appreciate any suggestions.