Interrupt Priority in timers interrupt dont'work

General discussion on mikroC PRO for PIC32.
Post Reply
Author
Message
gudezi
Posts: 1
Joined: 11 Jul 2015 18:47

Interrupt Priority in timers interrupt dont'work

#1 Post by gudezi » 14 May 2022 16:27

I wrote a small code that shows the error
I have two timers at different frequencies and each one at different priority interrupts.
add a couple of whiles to brake each subroutine separately and the inconvenience
is that regardless of the priority of each timer if I leave any of the two processes waiting
both interruptions are stopped I leave you a copy of the code
I would appreciate the help

Code: Select all


#define Led1 RB0_bit
#define Led2 RB1_bit
#define Led3 RB2_bit
#define Led4 RB3_bit

#define Btn1 RC1_bit
#define Btn2 RC2_bit

void InitTimer2_3(){
  T2CON                 = 0x8008;
  T3CON                 = 0x0;
  TMR2                  = 0;
  TMR3                  = 0;
  T3IP0_bit             = 1;
  T3IP1_bit             = 1;
  T3IP2_bit             = 1;
  T3IF_bit              = 0;
  T3IE_bit              = 1;
  PR2                   = 9216;
  PR3                   = 244;
}

void InitTimer4_5(){
  T4CON                 = 0x8008;
  T5CON                 = 0x0;
  TMR4                  = 0;
  TMR5                  = 0;
  T5IP0_bit             = 0;
  T5IP1_bit             = 1;
  T5IP2_bit             = 1;
  T5IF_bit              = 0;
  T5IE_bit              = 1;
  PR4                   = 46080;
  PR5                   = 1220;
}

void Timer2_3Interrupt() iv IVT_TIMER_3 ilevel 7 ics ICS_SRS{
  T3IF_bit = 0;
  Led2=!Led2;
  while(Btn2==1)
  {
  }
}

void Timer4_5Interrupt() iv IVT_TIMER_5 ilevel 6 ics ICS_SOFT{
  T5IF_bit = 0;
  Led1=!Led1;
  while(Btn1==1)
  {
  }
}

void main() {
  AD1PCFG = 0xFFFF;
  JTAGEN_bit = 0;

  TRISA = 0x00;
  TRISB = 0x00;
  TRISC = 0x00;
  TRISD = 0x00;
  TRISF = 0x00;
  TRISG = 0x00;

  LATA = 0;
  LATB = 0;
  LATC = 0;
  LATD = 0;
  LATF = 0;
  LATG = 0;

  TRISC = 0xFF;

  InitTimer2_3();
  InitTimer4_5();
  
  EnableInterrupts();

  while(1) {
    if(Btn1==1)
        Led3=1;
    else
        Led3=0;
        
    if(Btn2==1)
        Led4=1;
    else
        Led4=0;
  }
}

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Interrupt Priority in timers interrupt dont'work

#2 Post by filip » 02 Jun 2022 11:34

Hi,

Which MCU are you using ? Have you tried running the code through a debugger ?

Regards,
Filip.

Post Reply

Return to “mikroC PRO for PIC32 General”