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.

calling SPI Interrupt in timer interrupt routine

Other Parts Discussed in Thread: HALCOGEN, TMS570LS0432

Hello,

I am using TMS570LS0432 For Timer and SPI  i referred example in HALCoGen folder for SPI and timer Interrupt mode setting. 

When i call the SpiSendandGetData function in main function then i receive correct data from my slave device but when i call the same spi function in 100ms rtinotificaion then i am getting incorrect data

please give me solution if i am wrong with setting of interrupt selection.

Both timer and spi interrupts are IRQ interrupt .

Thanks & Regards

  • There is nothing wrong with calling SpiSendandGetData from a timer interrupt if the SPI is the master as the SpiSendandGetData function just sets up the structure and enables the interrupts. I am not sure it makes sense to use the timer function when the SPI is the slave since the timing of the SPI transfers is determined by the master spi. If the master is sending data every 100ms, just setup the slave to receive the data. It will wait until the master transmits and you will then get SPI interrupts (RX and/or TX). Setup the slave SPI for the next exchange immediately. The next transfer will not happen until the next 100ms pass and the master initiates the transfer.
  • Thank you for your quick reply

    For both RTI and SPI in IRQ interrupt mode it is not working.

    In datasheet i read that it is not possible to call IRQ interrupt in another IRQ interrupt. that's why i think it is  not working

    but when i set SPI in FIQ interrupt and RTI in IRQ interrupt then i will get correct data on SPI port

    but i want another interrupt on highest priority other than the SPI and RTI then how to set the priority of interrupt.

    Can you give any info related to re-entrant interrupt handling or any sample code for how i can create re-entrant interrupt for HALCoGen .

    Thanking you...

  • Hi Sameer,

    Interrupt Nesting is strongly not recommended for Safety Application.

    Is your application targeting any Safety? 

    Typically ISR's must be very quick, hence it should be of minimal code as possible.

    The CPU will automatically disable IRQ as soon as it enters in IRQ mode to avoid nested IRQ.
    It is possible within the IRQ service routine to re-enable IRQ. But I won't recommend this step unless as user you know what all context has to be taken care..

     

  • Ok.
    My application is safety related.
    but you didn't told me how can i interrupt the FIQ routine because i am running RTI IRQ interrupt for 100ms
    and in RTI interrupt i am sending SPI data in FIQ interrupt routine mode .suppose if i want other interrupt in higher priority other than the above RTI and SPI interrupt so how can i solve this issue.
  • The FIQ should be the highest level and should not be interrupted. Here is an application note discussing nested interrupts on IRQ. In most cases, nested interrupts are not required. Interrupt routines should be short and only perform highly time critical tasks. Extensive computations should be left for the main routine perhaps with a flag set in the interrupt routine to notify the main loop of new data to process.
    www.ti.com/.../spna219.pdf