View previous topic :: View next topic |
Author |
Message |
kokabt
Joined: 20 Nov 2012 Posts: 2
|
Cannot use Interrupt-on-change PIC16F1459 |
Posted: Mon Jul 27, 2015 3:35 am |
|
|
Hello,
I'm working a program on PIC16F1459 and i need to use interrupt on change.
Can please somebody help me why when i compile my program there is an error message: Invalid pre-processor directive on the line #INT_RB6_L2H. When i try to use other interrupts(example: INT_TIMER0) there is no error.
Thank you in advance. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Mon Jul 27, 2015 8:13 am |
|
|
No, it's a case of not quite understanding the chip, and how CCS handles it.
There is _not_ an interrupt 'INT_RB6_L2H'. There is a single #INT_RB (for all changes on port B), which can be programmed to only happen on pin RB6 changing from low to high.
So they are used like:
Code: |
#INT_RB //The handler is always just INT_RB
void RB_isr(void)
{
}
void main()
{
enable_interrupts(INT_RB6_L2H); //enable INT_RB to only sense RB6 low to high
enable_interrupts(GLOBAL);
|
You can't use the 'configuration' names, as names for the interrupt handler.
Separately, you may also have to manually clear the IOCBF register. This depends on the age of the compiler. The current ones do this for you, older versions in some cases do not. A search here will find code for this. |
|
|
kokabt
Joined: 20 Nov 2012 Posts: 2
|
|
Posted: Mon Jul 27, 2015 8:55 am |
|
|
Thank you Ttelmah,
now I understand. Your way works excellent. |
|
|
|