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.

Beginner to interrupts

Other Parts Discussed in Thread: CONTROLSUITE

To whom it may concern:

First, I don't know if this is posted in the correct spot.

I am new to posting to this community for the most part. I am creating an interrupt routine that services several interrupts to perform various tasks. The tasks are not really important for this question, except one. To give a bit more info, I have successfully used interrupts in two ways: starting on zero and CMPA trigger. Also, I am using an oscilloscope to observe the interrupts triggering and the tasks completing using GPIO registers. Everything looks great except again the one task. That task is transmitting bytes to a microSD card. First I buffer the data into a Uint16 variable[512] where the data is stored on high 8 bits to be read properly and transmitted into the SD card (because it is configured to read the upper 8 bits). The transmission of bytes isn't the issue, it is the spi commands to specify the sector and make sure the data is stored properly. This task (i.e., specifying a sector, sending bytes, and checking the SD card) takes 20+ ms. I am running the whole routine with a period of 6.6 ms. Every time I go to store data, the interrupt handling the data storage stops the rest of the interrupts from executing.

Diagram of my routine (setup and order):

`````Add epwm_isr()'s to PieVectTable

`````Reset EPwmxRegs.TBCTR

`````Enable CPU Interrupt 3

`````Setup EPwmxRegs for shape, phase, and period

`````Assign PieCtrlRegs.PIEIER3.bit.INTx for all interrupts

`````PIEIER3_CRIT all interrupts

`````Enable all interrupts

`````Add to clock all interrupts

`````Start timer

epwm3, 4, and 7 start synchronized on zero, and 5 and 6 start on CMPA a couple ms later. While the data is buffering (epwm7), epwm3 sits and waits. Once the buffer is full, epwm3 calls a function to store data. As mentioned before this takes a long time relative to the routine.

My question is, how do I remove this interrupt (epwm3 or INT3) from the IER group such that the other interrupts (4-7),can be used as normal every 6.6 ms (the specified period), while the other interrupt (epwm3) continues to store data and then restart (and be reinserted into the IER group) after it completes?

I hope my question makes sense. If you have any other questions regarding my routine, feel free to ask!

Thanks!

  • Benjamin,
    I am not quite sure I understand what exactly you are asking.
    Please correct me if I am wrong: You are calling a transmit function inside of your epwm3 ISR that is taking ~20ms and thus blocking the rest of your application from running. essentially your epwm3 ISR looks something like this:
    interrupt void epwm3_isr()
    {
    // buffer is full transmit it.
    for( i = 0; i<512; i++)
    spi_xmit(variable[i]);
    }

    If that is correct, it sounds like you are essentially blocking your application while the SPI transmits the entire 512 word buffer.

    What device are you working with?

    I think that I may have a few ideas but they assume that my interpretation is correct. Can you confirm my thoughts (or correct me) and then I may be able to give you a few pointers.

    -Mark
  • Mark,

    Thank you for seeking clarification. However, you quite eloquently restated most of what I am doing with your snippet of code. What you have is essentially what I am doing, except I also send spi commands that specify the sector in the SD card, and after transmitting the data, I verify that the data is written properly (example code made possible by Tom Love).

    I am using the Piccolo f28069. And you are correct, when the epwm3_isr starts to transmit the buffered data it prevents the other interrupts from executing, any proceeding period, until it is finished. It sounds like you may have suggestions, but to restate the question, I would like for epwm3_isr to do its thing without preventing the other isrs from triggering on the start of the next period.

    So,

    Period 0  

    INT1 start

    INT3 start (epwm3_isr waits

    ...

    INT7 start (epwm7_isr buffers 64 words)

    Period 1

    ""

    Period 8  

    ""

    Buffer full

    epwm3_isr transmits buffer

    Period 9

    INT1 start

    ...

    Start over, while epwm3 is still transmitting in the background

    Thanks,

    Ben

  • I can provide actual code if neceasary.

  • Benjamin,

    Thanks for the further clarification. It sounds to me like you want to decouple the actual SPI transmit/verify from you epwm3 ISR. Unfortunately for the SPI on F28069 there is no DMA to fully automate this. But it is still possible to break it up a bit. On  F2806x devices, you have a 4 word FIFO available. What you could do is Instead of Transmitting the data inside of the epwm3 isr, you could just enable the SPI transmit interrupt. you could fill the buffer, and every time the FIFO is below a certain level, it will receive another interrupt. You will need to get creative with how you want to verify the data as well as address which sectors are to be programmed. You might have to interleave your data, commands, and verification in the same ISR. Once your buffer is fully transmitted, you can disable the SPI interrupt and notify your epwm3 isr that you are ready to transmit again.

    This of course all assumes you actually have enough time in inside of your control loop to do all of this. you may need to make sure that the SPI does not starve any other interrupts and prevent them from running. 

    To summarize, it looks like you should investigate using the SPI FIFO interrupts to decouple the comms from the control loop in order to avoid blocking the rest of your application from running properly. Maybe look into creating a sort of state machine inside of your SPI ISR to handle transmitting the buffer, doing sd card commands, and verifying the data. 

    -Mark

  • I will look into doing this using the SPI FIFO interrupts. This would make sense, I will just have to figure out exactly how to do it. Thank you, Mark!

  • I'm glad I could help. Don't hesitate to ask any more questions. Good luck!
  • Could you point me in the direction of examples? I see that others in this community have provide some code related to this, but I cannot find examples in controlSUITE. Thanks!
  • The path would look something like this
    C:\ti\controlSUITE\device_support\f2806x\v141\F2806x_examples_ccsv5
  • Thanks! It was a matter of updating my version of controlSUITE.