This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS570 SPI interrupt

Other Parts Discussed in Thread: TMS570LS20216, HALCOGEN

Hello!

I'm using TMS570LS20216 and HALCOGEN and i was trying to run SPI connection.

I found topic on e2e:

http://e2e.ti.com/support/microcontrollers/hercules/f/312/t/344778.aspx

so i have tried to port this example(from last post) to my platform and it's impossible due to HALCOGEN'S disabled option of connecting interrupts (both RXINT and TXINT) to all of SPI modules. What is shown in picture below

And my question is how to enable interrupts? Is it somehow possible to bypass this inside code generated by HALCOGEN?

  • Hi Bartlomiej,

    Unfortunately on device TMS570LS20216 we do not have compatibility Mode Driver support in HALCoGen. It only supports MIBSPI mode. MIBSPI mode does not need TX and RX Interrupt since Transfer Group Interrupts are used.

    The example provided is for different device which has compatibility mode SPI support.

    Meaning spi.c generated by HALCoGen for TMS570LS20216 is mibspi driver and for other devices spi.c is compatibilty mode driver and mibspi.c is mibspi driver.

    If you want I can generate an example for you, but this particular spi driver will be out side HALCoGen... Let me know if you need it.

  • Thank you for quick anwser!

    I would be thankful if you send me this example. Does this file would work with rest of the init(CAN, SCI, RTOS) from halcogen?

  • Sure you can use other drivers. All you have to do is to Disable SPI Driver in Driver Eable TAB. And Include the files that I send.

  • Hi Bartlomiej,

    Please find the attached project file that has Master and Slave configuration example.
    comp_spi.c, comp_spi.h and comp_reg_spi.h.

    4101.SPI_MASTER_SLAVE_20x.zip

    SPI1 is Master configured in Polling mode, SPI3 is Slave in Interrupt mode.

    Connect SIMO to SIMO, SOMI to SOMI, CLK to CLK and CS0 to CS0 pins of SPI1 and SPI3 respectively.

    Note : I do not have the hardware to test, I did only compile, check. But I think It should work. Let me know if you find some issue.

  • Thank you for this file! However this example does not work :(

    I have opened this project as it is in CCS.

    As you told me i have connected PINS(double-checked it):
    MIBSPI1CLK to MIBSPI3CLK
    MIBSPI1CS[0] to MIBSPI3CS[0]
    MIBSPI1SIMO to MIBSPI3SIMO
    MIBSPI1SOMI to MIBSPI3SOMI

    Then compiled & run this project(i have set breakpoint on while(1);). After transmission commands RX_Data_Slave does not recive any data at all, RX_Data_Master fills with zeros(i have changed init values to check if any data comes).

    It seems that slave(SPI3) pulls to "0" SOMI and does not recive anything - so it looks like it's not init'ed...

    Do you have any futher idea what can be wrong? 

  • Can you please change the below line in comp_spi.c.. Clock must be external for Slave..    

    spiREG3->GCR1 = (spiREG3->GCR1 & 0xFFFFFFFCU) | ((uint32)((uint32)0U << 1U) /* CLOKMOD */
    | 0U); /* MASTER */

  • Thank you again! It works now

  • Should I expect this code to run on my TMS570LS12 HDK? What I am seeing is that the master sends 0xFFFF (for some reason that's in spi->BUF when it sends, and the interrupt-driven slave does see that, but then it just stops (still trying to debug it).
  • Prathap, hopefully you are still on the case...
    Should I expect this code to run on my TMS570LS12 HDK? What I am seeing is that the master sends 0xFFFF (for some reason that's in spi->BUF when it sends, and the interrupt-driven slave does see that, but then it just stops (still trying to debug it).
  • Hi Thomas,

    Quick question, Did you do the following connection between SPI1 and SPI3? 

    SIMO to SIMO
    SOMI to SOMI
    CLK to CLK
    CS0 to CS0

  • Hi Prathap, yes, but I will check wire-by-wire with an ohm meter to make sure they are actually connected...

    What I am seeing in this code is that the value of (uint16)spi->BUF is always FFFF (in spiTransmitAndReceiveData() ). If I single step through it executes all of "blocksize" but if I just put breakpoints in the slave's interrupt handlers it seems to stop after the first FFFF (which appears in both the slave and master's RX buffers). I haven't figured out why it just stops with that single FFFF (I assume single-step disables interrupts).


    while(blocksize != 0U)
    {
    if((spi->FLG & 0x000000FFU) != 0U)
    {
    break;
    }

    if(blocksize == 1U)
    {
    Chip_Select_Hold = 0U;
    }
    /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
    Tx_Data = *srcbuff;

    spi->DAT1 =((uint32)DataFormat << 24U) |
    ((uint32)ChipSelect << 16U) |
    (WDelay) |
    (Chip_Select_Hold) |
    (uint32)Tx_Data;
    /*SAFETYMCUSW 567 S MR:17.1,17.4 <APPROVED> "Pointer increment needed" */
    srcbuff++;
    /*SAFETYMCUSW 28 D MR:NA <APPROVED> "Hardware status bit read check" */
    while((spi->FLG & 0x00000100U) != 0x00000100U)
    {
    } /* Wait */
    /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
    *destbuff = (uint16)spi->BUF;
    /*SAFETYMCUSW 567 S MR:17.1,17.4 <APPROVED> "Pointer increment needed" */
    destbuff++;

    blocksize--;
    }
  • I found my bug!!!

    instead of spiREG3->GCR1 = (spiREG3->GCR1 & 0xFFFFFFFCU) | ((uint32)((uint32)0U << 1U) /* CLOKMOD */

    | 0U); /* MASTER */

    I had this:

    spiREG3->GCR1 = (spiREG3->GCR1 & 0xFFFFFFFCU) | ((uint32)((uint32)1U << 0U) /* CLOKMOD */
    | 0U); /* MASTER */    BAD DO NOT DO THIS!!!!!  WRONG WRONGE 

    so the demo DOES work on the TMS570HDK

  • Hi Thomas,

    I am glad it worked.

    Sorry, I was under assumption you already took care of this bug, since I posted the same fix in the earlier response to same thread on Jul 3, 2014

    Let me know if you further assistance on this query else please verify answer to close the ticket. Thanks!