SPI returns an error (06) SSP_ERROR_UNSSUPORTED

Hello

I am trying to use the SPI on CH0 on a R7FS124763 (48QFP)

 

I open a instance of the SPI port with err = g_spio.p_api->open(g_spio.p_ctrl. g_spio.p_cfg)  I get

err = SSP_SUCCESS returned.

 

When I run     err = g_spio.p_api->write(g_spio.p_ctrl. mess, 4, SPI_BIT_WIDTH_8_BITS )  I get 

err = SSP_ERROR_UNSSUPORTED which is register value 0x06

 

There is no error in the SPI H/W manual with that value ?

 

 

  • CMB,

     

    Check your syntax it appears incorrect:

    your posted syntax:  err = g_spio.p_api->write(g_spio.p_ctrl. mess, 4, SPI_BIT_WIDTH_8_BITS )

    Correct Syntax:  g_spi.p_api->write (g_spi.p_ctrl, &mess, 4, SPI_BIT_WIDTH_8_BITS);

     

    The parameters are the control, Address of message buffer, Length of message, SPI Message mode

  • In reply to Michael Quirk:

    Hi Michael - I failed to show in my post above I had cast the array as a pointer with the (const uint8_t *). I did this because when I put the mouse over the write it showed me that the pointer was a void pointer.

    I tried removing my cast and replacing it with the & operator but I still have the same problem.
  • In reply to cmb:

    That is fine for the operation of the pointer.  What I am concerned about is that you have a Period instead of a comma on your original post =>

    err = g_spio.p_api->write(g_spio.p_ctrl. mess, 4, SPI_BIT_WIDTH_8_BITS )

     

    Can you tell me is it a period or a comma.  It should be a comma.

  • In reply to Michael Quirk:

    Thanks for your thoroughness but Yes it is a comma, the syntax in my code is correct because it compiles and runs. When I posted the question I did this on another PC and did not copy and paste and ended up creating syntax errors.

    I found the problem by removing the DTC channels for Rx and Tx in the SSC. This removed the SSP_ERROR_UNSSUPORTED. which was confusing because it is NOT mentioned anywhere in the documents.

    The only problem I see right now is that the CS (SSL0) line is being asserted for every byte sent on the SPI bus and should be asserted after a complete command NOT for every byte in the command ?. Not sure if I can set this up in the SSC ?
  • In reply to cmb:

    Hi cmb,

    If change the SPI properties for SPI Mode to Clock Synchronous Operation, the SSL should stay asserted for the entire operation. Normally, you would use GPIO instead of the SSL line controled by the SPI module. The framework layer driver does this. You should read through the MCU users manual on the SPI hardware to better understand the property settings in the SSC.

    The issue with the DTC is that you requested a transfer size of 1 byte but the DTC default was set to two bytes. This is why you were getting the unsupported operation error.

    -Gary
  • In reply to garyj:

    Thanks Gary and Michael -

    All sorted and working.

    Removed SSL0 from peripheral for SCI and made it a GPIO. Added interrupt option in SSC then set a flag in interrupt handler when transfer operation complete, then use this flag to deassert the SSL0 line if end of operation.

    Thanks