Multiple software interrupts

Development environment specific, Arduino, Eclipse, VS2013, Em::Blocks etc
Post Reply
mebab
Posts: 115
Joined: Mon Aug 24, 2020 12:42 pm
Answers: 4

Multiple software interrupts

Post by mebab »

I am setting up two software interrupts in 1 Hz and 100 Hz as follows:

Code: Select all

  #if defined(TIM1)
    TIM_TypeDef *Instance = TIM1;
  #else
    TIM_TypeDef *Instance = TIM2;
  #endif
  
  HardwareTimer *MyTim = new HardwareTimer(Instance);
  MyTim->setOverflow(100, HERTZ_FORMAT);
  MyTim->attachInterrupt(SensorReading);
  MyTim->resume();
 
  #if defined(TIM6)
    TIM_TypeDef *Instance1 = TIM6;
  #else
    TIM_TypeDef *Instance1 = TIM7;
  #endif
  
  HardwareTimer *MyTim1 = new HardwareTimer(Instance1);
  MyTim1->setOverflow(1, HERTZ_FORMAT);
  MyTim1->attachInterrupt(LED_ONOFF);
  MyTim1->resume();  
  
The problem is that the time of 1 Hz for LED on/off is not kept fixed. What might be wrong with the above setup? How will be the priority of two interrupts in comparison to each other?

Thanks for any help.
Post Reply

Return to “IDE's”