Interrupt task stack

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Interrupt task stack

1,133 Views
Mohsin455
Contributor IV

Hi All,

 

              I am using MQX3.8 and IAR tools in my project. I have written my own interrupt drivers for UART and I2S (using DMA) and have installed the interrupts using _int_install_isr().

 

The problem I have is the interrupt task stack keeps growing if I leave the program for some time. I think, I might be getting I2S interrupts while another (UART) interrupts is being serviced (althought my ISR routines are not doing much).

 

Can anyone please provide information how do we tackle this situation ?

 

Do I have to disable the interrupts at the start of ISR and enable just before leaving ?

 

Thanks,

Mohsin455

Tags (3)
0 Kudos
5 Replies

400 Views
Mohsin455
Contributor IV

Few more questions

 

Also is it possible for higher priority interrupts to come in when lower priority interrupt is being serviced ?

 

And how do we change the priority of interrupts in MQX ?

 

Thanks,

Mohsin455

0 Kudos

400 Views
Mohsin455
Contributor IV

Hi All,

 

              Is there any rule on the size of the Interrupt stack which is defined in the linker file ?

 

I am having this issue where the interrupt stack keeps growing when the audio DMA interupts are enabled. Can anyone explaing how the interrupt are handled.

 

Thanks,

Mohsin455

0 Kudos

400 Views
c0170
Senior Contributor III

Hello Mohsin455,

 

The interrupt stack is only one for all interrupts. If they are nested (higher priority interrupt preempts the lower priority interrupt), then the usage of the stack is higher. You have to setup the size of interrupt stack to be as big as it could not overflow.

 

If you have the feeling that the interrupt usage grows to infinite size, then that is only feeling. An interrupt cannot be preempted with the interrupt of lower priority or the same priority.


To setup the priority of the interrupt, use _bsp_int_install macro.

 

Regards,

MartinK

0 Kudos

400 Views
Mohsin455
Contributor IV

Hi Kojto,

                 I have found that the tick timer runs at priority of 2 and my I2S dma was running at priority 3. Changing the priority of I2S DMA to priority 2 (same as tick timer) keeps the interrupt stack at around 22%.

Since my I2S block size is 256, the I2S DMA interrupts will also be comming at 5 ms rate. But still I dont understand why making the I2S dma lower priority than Tick timer increasing the stack usage by that amount (and I think it keeps growing if I leave it running).

I would have thought it would stabilize to some amount after starup with few second and would be steady. Any clues ?

Thanks,

Mohsin455

0 Kudos

400 Views
Mohsin455
Contributor IV

Hi MartinK,

 

                      I am using _cortex_int_init to set the priority.

 

_cortex_int_init(INT_DMA1, 3, TRUE);                     // rx DMA interrupt

 _cortex_int_init(INT_DMA0, 3, TRUE);                    // tx DMA interrupt

 _cortex_int_init(INT_UART0_RX_TX, 4, TRUE);   // UART0 interrupt

And below is one of my audio DMA ISR.

 

static void
dma_tx_ch0_isr(
    pointer foo
) {  
    DMA_CINT = DMA_CINT_CINT(0);            /* Use the Clear Intr. Request register */
 
    if (dma_tx_buff_in_use_a) {    
        /*
        ** Finished playing Buffer A             
        */
        DMA_TCD0_SADDR     = (uint32) &dma_tx_buff[BUFF_SIZE];
        dma_tx_buff_in_use_a = FALSE;
    }
    else{
        DMA_TCD0_SADDR     = (uint32) &dma_tx_buff[0];
        dma_tx_buff_in_use_a = TRUE;
    }
    
    /*
    ** DMA finished playback
    */
    _event_set(dma_tx_rx_dma_ready,0x01);
}

 

If I comment out _event_set(dma_tx_rx_dma_ready,0x01) the stack grows very slowly but putting this back in it grows very quickly and reaches 88% of size (1024).

 

Also what are the interrupts which are assigned by default in MQX. I want to see what are the priorities of other interrupts i.e. Ethernet, etc.

 

Thanks,

Mohsin455

0 Kudos