Easy Timer Interrupts with MikroElektronika

preview_player
Показать описание
Easy Timer Interrupts with MikroElektronika and their own Timer Calculator. Easy as 1 2 3
Рекомендации по теме
Комментарии
Автор

Hi John, I really thank you for this video. I am trying to use this calculator to set a timer for a solenoid valve, any tips on how to do it?

thanks

strangee
Автор

help me
interrupt priority don't work

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


#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;
}
}

gustavojosedezi