AnsweredAssumed Answered

I2S Interrupt and Optimisation

Question asked by alex.001 on Sep 10, 2013
Latest reply on Sep 11, 2013 by alex.001
Hello All.

In my app. I have I2S Transmitter with External Clock.
I want to test the clock frequency.
At clocktest.c I make:
[code]
volatile u32 clknum;
extern volatile u32 SendTmr;

void ClockTest(void){
     Delay(10);
     SendTmr=0;
     Delay(100);
     clknum = SendTmr;
}
[/code]

and in stm32f4xx_it.c I make:
[code]
volatile u32 SendTmr;
//
void SPI3_IRQHandler(void){
volatile static u32 status;
 
  status = SPI3->SR;
  SPI3->DR = 0;
  SendTmr++;
}
[/code]

Global optimisation settings:  Level2, Optimise for time.
All works fine, if I set localy for stm32f4xx_it.c: no "optimise for time" and Level0.
If I use global settings to this file - I gen the wrong number in SendTmr and also in clknum.

But, if I add test_pin_toggle() at the end of interrupt subrotine all works fine with optimisation global settng.
[code]
volatile u32 SendTmr;
//
void SPI3_IRQHandler(void){
volatile static u32 status;
 
  status = SPI3->SR;
  SPI3->DR = 0;
  SendTmr++;
 test_pin_toggle();
}
[/code]

I can leave pin toggle forever, but it is not a good idea, because I don't understand what happened.
What to do?

Thank you.

Outcomes