• AVR Freaks

Calling Interrupt in XC8 compiler

Author
AMPS
Super Member
  • Total Posts : 399
  • Reward points : 0
  • Status: offline
2019/07/12 20:11:35 (permalink)
0

Calling Interrupt in XC8 compiler

Dear all
I am using PIC18F24k40. I dont want to use MCC generated Interrupt function. I have config I/O device using MCC for LED blinking. Let me know how can i call Interrupt Here.
 
#include <xc.h>
#include "mcc_generated_files/mcc.h"

//#define LED LATC2
//#define LED1 LATC3

#define LED RC2
#define LED1 RC3

unsigned char Dgt=0;

void interrupt Hight_Int_Event() {
 if(PIE0bits.TMR0IE == 1 && PIR0bits.TMR0IF == 1) {
  TMR0H=0xFF; // Load the time value(0xBDC) for 100ms delay
  TMR0L =0xDC;
  PIR0bits.TMR0IF=0;
  Dgt++;
  if(Dgt>=5) {
   LED1=!LED1;
   LED=!LED;
   Dgt=0;
  }

 }



}





void main(void) {
 // Initialize the device
 SYSTEM_Initialize();
 INTCONbits.GIE=1;
 INTCONbits.PEIE=1;
 // If using interrupts in PIC18 High/Low Priority Mode you need to enable the Global High and Low Interrupts
 // If using interrupts in PIC Mid-Range Compatibility Mode you need to enable the Global and Peripheral Interrupts
 // Use the following macros to:

 // Enable the Global Interrupts
 //INTERRUPT_GlobalInterruptEnable();

 // Disable the Global Interrupts
 //INTERRUPT_GlobalInterruptDisable();

 // Enable the Peripheral Interrupts
 //INTERRUPT_PeripheralInterruptEnable();

 // Disable the Peripheral Interrupts
 //INTERRUPT_PeripheralInterruptDisable();

 while (1) {
  // Add your application code
 }
}

post edited by AMPS - 2019/07/12 20:15:31

Attached Image(s)


Amps
*.*.*.*.*.*.*.*.*.*.*.*.*
#1

2 Replies Related Threads

    ric
    Super Member
    • Total Posts : 22661
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Calling Interrupt in XC8 compiler 2019/07/12 21:59:22 (permalink)
    +1 (1)
    If you are not getting MCC to enable the interrupts, then you are going to have to set PIE0bits.TMR0IE yourself.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    pcbbc
    Super Member
    • Total Posts : 1092
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: online
    Re: Calling Interrupt in XC8 compiler 2019/07/13 00:57:06 (permalink)
    +2 (2)
    It’s __interrupt() with XC8 version 2.05 in C99 mode.
    And you don’t “call” interrupts. You can “enable” them, but they get “called” for you.
    #3
    Jump to:
    © 2019 APG vNext Commercial Version 4.5