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.

ti hercules spi interrupt

Other Parts Discussed in Thread: TMS570LS0432, HALCOGEN, RM42L432

hello all,

I'm working on hercules tms570ls0432 launchpad.I want to do spi example with interrupt,So I want to use spiNotification() function, But I didn't understand function parameter of flags.What should be the flag parameter?

I'd appreciate if you can help.

Best Regards

Ahican

  • Ahican,

    look at esm.h and esm.c for example of how to create an interrupt using pragma.

    You need to define an spi interrupt function and using #pragma to assign it to VIM interrupt line.

    Then, inside this interrupt function, you can call back the spiNotification() function to do whatever you want to do.

    when do the call back, pass in the flag register values like spi->FLG where spi is the pointer to your SPI base address in your current scope.  e.g. spiREG4.

    Hope this help.

  • Dear Henry,

    Firstly,thanks for your response.

    I have already looked at esm.h and esm.c. In addition, I found spiNotification()  function decleration in spi.c and spi.h,,so I've learned flags parameter,and I can use spiNotification function,But I have another question.I am trying to spi master slave example in HalCoGen(for TMS570LS04x). 

    ***spiSendAndGetData(spiREG2, &dataconfig1_t, 16, TX_Data_Master, RX_Data_Slave);

    I used above code,but RX_Data_Slave buffer didn't change.My Halcogen is true according to example steps.

    I'd appreciate if you help again.

    Best Regards

    Ahican.

      

  • Ahican,

    This topic has been discussed quite a bit in the forum.

    You an do a small search.

    here is a few example link:

    http://e2e.ti.com/support/microcontrollers/hercules/f/312/p/201440/727311.aspx#727311

    http://e2e.ti.com/support/microcontrollers/hercules/f/312/p/277903/970279.aspx#970279

    Hope this helps you...

  • Ahican,

    I've created a simple project running on the launch pad to demonstrate the usage of spiEndNotification().

    In this example, spiSendAndGetData() function is used to send 16 data via SPI2.
    To simplify the code and the hardware, SPI2 is configured in analog loop back mode. That means that all data send on the SIMO pins are loop back on the SOMI. In other words, each data that are transmitted out are also received.

    spiSendAndGetData() uses interrupt and a call to spiEndNotification() is done when the full buffer is transmitted. In this example, 16 datas.

    In the main code, after the call to spiSendAndGetData() the code is in a while loop and increment a counter while waiting for a flag (done) to be set. The spiEndNotification() is setting this flag when the transmission is finished.

    While the SPI is transmitting the 16 datas, the CPU is free to do something else.

    Please have a try and let me know if this code is helpful.

    1488.SPI_Transmit_Interrupt.zip

  • Dear Jean-Marc,

    Thank you for your interest my question.Your code is running ,but you used only spi2.I want to do spi communication between spi1 and spi2 on a tms570ls0432 (just one evaluation kit).For this, firstly I am trying spi master and slave example in HalCoGen help menu. I did this example but, RX_Data_Slave[0]=0 , RX_Data_Slave[1]=0 ...

    I am not sure HalCoGen parts.

    This file contains an example of SPI1 and SPI2 Master / Slave configurations.
    *
    * PIN Connections must be as Below
    * --------------- ---------------
    * SPI1 ( Master ) SPI2 ( SLave)
    * --------------- ---------------
    * SIM0 ---> SIMO
    * S0MI <--- SOMI
    * CLK ---> CLK
    * CS0 ---> CS0
    *
    * ------------------
    * GUI configurations
    * ------------------
    * 1) Driver TAB
    * - Select SPI2
    * - Select SPI1
    * 2) VIm Channel 0-31
    * - Enable SPI2 Level 0 and Level 1 channels.
    * 3) SPI2 TAB
    * - SPI2 Global SubTAB
    * - Uncheck Master Mode
    * - Uncheck Internal Clock
    * - SPI2 Port SubTAB
    * - Uncheck DIR for CS 0
    * 3) SPI1 TAB
    * - Have it default
    * 4) Generate Code.

    If you let me I want ask another question:

    I want to do new spi communication between tms570ls0432 and rm42l432.

    is it possible ? 

    In addition, How should be pin configuration on HalCoGen?

    I'd appreciate if you help me.

    Best Regards,

    Ahican

    Electronic Engineer

     

  • I have tried the example 1488.SPI_5F00_Transmit_5F00_Interrupt.zip It seems to copy15 datas (0-14), not 15. I've uploaded a screenprint from the watch view.
  • Jan,

    I've checked the code and it is working correctly.

    Are you using breakpoint when you execute this test?
    If yes, this could be the reason.

    Load and run the code without breakpoint. There is a while loop at the end so the CPU will not go in the weed.

    After execution, halt the CPU. It will be in this while loop. Check the TX_Data_Master and RX_Data_Master.
    All data are sent and received.

    Please let me know the result of your test.

  • I will test... I had put a breakpoint at the very end where the Transfer should have been finished. I'll post the results.
  • (don't know why my post doesn't show newlines. In preview it looks ok ) I did a retest, and it works indeed. My findings: I put a breakpoint on line 65 of sys_main.c: 60: printf("TX_Data_Master has been sent out and should be received in RX_Data_Master\n"); 61: while(done==0) 62: { 63: counter++; 64: } 65: printf("buffer has been successfully sent\n"); // breakpoint here This is after the spiEndNotification() handler has been called. The expressions window shows that RX_Data_Master[0..14] are copied. RX_Data_Master[15] == 0 (as in the screenprint I uploaded above). When I step over line 65, also the RX_Data_Master[15] shows the copied data. I was thinking that the buffer would have been completely transfered when the spiEndNotification() fired...
  • Hi,

        Thanks for your replay, and I have worked out  the spi communication. thanks.