|
|
View previous topic :: View next topic |
Author |
Message |
jbw Guest
|
INT_RB1_H2L on PIC16lf1936 |
Posted: Fri Feb 12, 2010 6:25 pm |
|
|
I need to use a High to low interrupt on PIN_B1. The header file for the part defines INT_RB1_H2L, I have tried to use this to make an interrupt when RB1 goes high to low (using #INT_RB1_H2L) but it will not compile.
Looking at the "Valid interupts" tab in PCW it does not list RB1_H2L as a valid interrupt. It only list RB which will interrupt on change of PINB4-7
The datasheet confirms that RB1 can be used to interrupt on high to low.
So what am I missing? Do I have to make my own interrupt handler?
Thanks,
Josh |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Feb 12, 2010 10:34 pm |
|
|
What is your compiler version ? |
|
|
Ttelmah Guest
|
|
Posted: Sun Feb 14, 2010 10:44 am |
|
|
Realistically, I'd just set the control bits myself.
CCS, are trying to offer to do this for you, but have obviously not got it working yet.
There is only one interrupt used for this, and this would be the INT_RB interrupt, but what they are doing is offering to set just the bits to enable the interrupts on particular pins, and then to add the code to test which pin has interrupted, and vector to the particular routine. If you are only using one, this latter is just wasted space/time, so it only becomes a matter of setting up the control registers to enable the correct pin and edge.
You'd need something like:
Code: |
#byte IOCBP=0x394
#byte IOCBN=0x395
#byte IOCBF=0x396
#int_rb
void changed(void) {
if (IOCBF & 2) {
//Here RB1 has triggered an interrupt - handle
}
IOCBF=0;
}
//Then in main
IOCBN=2; //enables negative edge interrupt on B1
IOCBP=0; //Disable all positive edge interrupts
IOCBF=0; //Clear any flags set by this
clear_interrupts(INT_RB);
enable_interrupts(INT_RB);
enable_interrupts(GLOBAL);
//and on to your main code...
|
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|