• AVR Freaks

Helpful ReplyHot!Interrupt routine in XC8

Page: < 12 Showing page 2 of 2
Author
mad_c
Super Member
  • Total Posts : 1247
  • Reward points : 0
  • Joined: 2010/12/12 17:48:27
  • Location: Brisbane, Australia
  • Status: offline
Re: Interrupt routine in XC8 2019/05/08 13:38:37 (permalink)
+3 (3)
DungeonLords
 
How to set interrupt via XC8 for Atmega?

Make sure that you are building with CCI enabled. Use either the command line option -mext=cci, or in the MPLAB X IDE, go to your properties > XC8 Compiler > Preprocessing and Messaging > Use CCI syntax.
 
It looks like the interrupt section in the user's guide was the only one to omit the requirement for this option if you want to use the new syntax. I'll make a note to correct that.
 
Jeff.
 
#21
DungeonLords
New Member
  • Total Posts : 9
  • Reward points : 0
  • Joined: 2019/05/05 08:41:21
  • Location: 0
  • Status: offline
Re: Interrupt routine in XC8 2019/08/26 07:49:43 (permalink)
0
At ATMega128A, XC 2.05 with CCI syntax C99, but the code not work, LED not on. I do not use USART0, so UDR0 is empty and UDRE interrupt must be done, but nothing.

#include <xc.h>
void __interrupt(USART0_UDRE_vect_num) myISR(void){    
    PORTA|=(1<<2); //set "1" on PA2
    return;
}
int main(void) {
    DDRA|=(1<<2);
...
    ei();
}
 
I use different vect num to try interrupt just be done, but nothing. What wrong? Full code https://yadi.sk/d/ioboSWMRhSJZtg
#22
Binene82
New Member
  • Total Posts : 1
  • Reward points : 0
  • Joined: 2020/02/14 14:46:05
  • Location: 0
  • Status: offline
Re: Interrupt routine in XC8 2020/02/26 01:14:00 (permalink)
-1 (1)
 
Hi I am using MP LAB IDE V5.30 AND XC8 V2.10
I am trying to write an interrupt  service routine but it is giving me errors
this one :  Interrupt.c:13:7: error: variable has incomplete type 'void'
 
please assist me 
here is my code 
 
void  interrupt   my_isr ()
{
    if (INTCONbits.INT0IE==1)// if (INT0IE=1) to check if the PIR IS PRESSED FOR INTERRUPTION
    {
        for (int flahD2=0;flahD2 <5;flahD2++) // THE LED WILL FLAH 5 TIMES
        {
            LATBbits.LATB5=1;
       for (int count =0;count<20;count++)__delay_ms(13);// delay for 330ms
        LATBbits.LATB5=0;
       for (int count=0;count <20;count++)__delay_ms(13);// delay for 330ms
        }
     
    }
    INTCONbits.INT0IF  =0;// clear the interrupt
   
}
 
#23
katela
Super Member
  • Total Posts : 1830
  • Reward points : 0
  • Joined: 2013/06/11 05:25:18
  • Location: South Africa
  • Status: offline
Re: Interrupt routine in XC8 2020/02/26 08:17:23 (permalink)
+2 (2)
Did you read post #3 for the new interrupt syntax when using XC8 from version v2 (C99 mode)?

Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
YouTube Tutorials: https://www.youtube.com/StudentCompanionSA
#24
Page: < 12 Showing page 2 of 2
Jump to:
© 2020 APG vNext Commercial Version 4.5