Libstock interrupt examples for 18F45K22

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
Lord Lucan
Posts: 60
Joined: 09 Dec 2010 14:41

Libstock interrupt examples for 18F45K22

#1 Post by Lord Lucan » 29 Jul 2014 03:27

In the example the interrupt routine reads as follows:

Code: Select all

void interrupt(){           // Interrupt rutine
  if(INT0F_bit == 1 ) {     // Checks Receive Interrupt Flag bit
    flag      = 1;          // Set local interrupt flag
    INT0F_bit = 0;          // Clear Interrupt Flag
  }
}

Shouldn't the INT0F statements be INT0IF?

:wink:

ST.

User avatar
marina.petrovic
Posts: 2986
Joined: 18 Apr 2013 08:11

Re: Libstock interrupt examples for 18F45K22

#2 Post by marina.petrovic » 29 Jul 2014 14:47

Hi,

According to datasheet bit 1 in INTCON register is INT0IF (INT0IF_bit),
but if you take a look at PIC18F45K22 definition file in compiler (Ctrl + Alt + D),
you can see that you can use INT0IF_bit or INT0F_bit equally, because, both corresponding to INTCON bit 1.

Code: Select all

// INTCON bits
...
   const register unsigned short int INT0IF = 1;
   sbit  INT0IF_bit at INTCON.B1;
...
   const register unsigned short int INT0F = 1;
   sbit  INT0F_bit at INTCON.B1;
...
Best regards,
Marina

Lord Lucan
Posts: 60
Joined: 09 Dec 2010 14:41

Re: Libstock interrupt examples for 18F45K22

#3 Post by Lord Lucan » 30 Jul 2014 03:26

Ah! Okay...

One more thing, the example sets the interrupt to activate on a rising edge but the datasheet indicates that RB0 - RB2 have internal pull-ups - is that going to work?

I'm coding at the moment and I haven't had the chance to test on hardware yet.

ST.

User avatar
marina.petrovic
Posts: 2986
Joined: 18 Apr 2013 08:11

Re: Libstock interrupt examples for 18F45K22

#4 Post by marina.petrovic » 30 Jul 2014 10:21

Hi,

Examples posted on LibStock Website by MikroElektronika are tested.

As the example is written for EasyPIC v7 board - PIC18F45K22, at the beginning of the example you can find note:
"Put PORTB dip switch RB0 in PullDown position".

Best regards,
Marina

AllenM
Posts: 75
Joined: 20 Mar 2013 17:30
Location: Rome, NY, USA

Re: Libstock interrupt examples for 18F45K22

#5 Post by AllenM » 31 Jul 2014 18:56

The internal interrupts need to be enabled in your program for them to work. I think the default is that they are turned off.

Post Reply

Return to “mikroC PRO for PIC General”