Abdulkerim
Junior Member level 1
hi dears
i have a small project that use atmega32 (MICROC FOR AVR)
i need to use 3 interrupts INT0, INT1, INT2 with TIMER1
1. INT0 to detect ZERO CROSSING
2. INT1 to detect MOTOR SPEED
3. INT2 to detect some EXTERNAL FEEDBACK
note that I have no any library or headers for INTERRUPTS
MY CODE:
thats my code
but it dosnt compiling
thank you for help
i have a small project that use atmega32 (MICROC FOR AVR)
i need to use 3 interrupts INT0, INT1, INT2 with TIMER1
1. INT0 to detect ZERO CROSSING
2. INT1 to detect MOTOR SPEED
3. INT2 to detect some EXTERNAL FEEDBACK
note that I have no any library or headers for INTERRUPTS
MY CODE:
Code:
void Timer1Overflow_ISR() org IVT_ADDR_TIMER1_COMPA
{
MS++;
}
ISR (INT0_VECT)
{
return ZC_FLAG = 1;
/// have i reset INT0 flag here? ///
}
ISR (INT1_VECT)
{
return TCHO_FLAG = 1;
/// have i reset INT1 flag here? ///
}
ISR (INT2_VECT)
{
return FEEDBACK_FLAG = 1;
/// have i reset INT2 flag here? ///
}
void main (void)
{
/// TIMER1 ///
SREG.B7 = 1; // ENABLE GLOBAL INTERRUPT BIT
TCCR1A = 0x80;
TCCR1B = 0x0B;
OCR1AH = 0x30;
OCR1AL = 0xD3;
OCIE1A_bit = 1;
/// EXT_INTS ///
SREG.B7 = 0;
GICR.B6 = 1; // INT0 ENABLE
GICR.B7 = 1; // INT1 ENABLE
GICR.B5 = 1; // INT2 ENABLE
MCUCR.B0 = 0; MCUCR.B1 = 1; // INT0 FALLING EDGE
MCUCR.B2 = 0; MCUCR.B3 = 1; // INT1 FALLING EDGE
MCUCSR.B6 = 0; // INT2 FALLING EDGE
SREG.B7 = 1; // ENABLE GLOBAL INTERRUPTS
while (1)
{
if (ZC_FLAG) {
// do somethings //
ZC_FLAG = 0;
}
if (TACHO_FLAG) {
// do somethings //
TACHO_FLAG = 0;
}
if (FEEDBACK_FLAG) {
// do somethings //
FEEDBACK_FLAG = 0;
}
}
}
/// END CODE //
thats my code
but it dosnt compiling
thank you for help