EEVblog Electronics Community Forum
Electronics => Microcontrollers => Topic started by: Spock on September 29, 2013, 10:28:55 pm
-
Hi all,
After few hours of fighting maybe someone tell me why this is't working:
I have 44-PIN demo board (the same Dave made bug soldering video). I'm attemting to run edge based interrupt on SW1 connected to RB0.
Here is my code:
TRISD = 0x0;
PORTD = 0x0;
//setup RB0 interrupt
TRISBbits.RB0 = 1; //RB0 input
INTCON2bits.INTEDG0 = 0; //falling edge
INTCONbits.INT0IE = 1; //INT0 enable
INTCONbits.INT0IF = 0; // clear Int flag
ei();
// interrupt ISR
void interrupt low_priority ISR() {
if (INTCONbits.INT0IF == 1) {
LATD0 = ~LATD0;
INTCONbits.INT0IF = 0;
}
}
I checked with DMM that after pushing button voltage drops from 3,3 ->0 V.
Any idea what is wrong ? Debugger is showing that IOCON INT0IF is not "1" even if I push button.
-
I have 44-PIN demo board (the same Dave made bug soldering video). I'm attemting to run edge based interrupt on SW1 connected to RB0.
A PIC18F in a 44 pin package - doesn't narrow it down much does it?
You should check the other possible functions of the pin you are using and make sure they are not enabled. Pins with analog functions have the analog function enabled from reset for example.
-
void interrupt low_priority ISR() {
1. You aren't helping your cause by providing half of the story;
2. Read the interrupt tree in the datasheet and you will understand your issue.
-
@Rufus
You made my sleep good :) It was default AN12 A/D input.
It was ~1 A.M when I finish my fight with this, and start this thread.
When you post your response (got smartphone ring) I thought damn why I wasn't got this.
I walk to my lab, launch MPLAB and check - it worked, check datascheet where is it written with * on bottom of one pages :/
Thanks
@dannyf
I tested with and without low_priority, and enabled prioritizing interrupts - stil not working. It was default pin mode ..
-
check datascheet where is it written with * on bottom of one pages :/
All the PICs (low-end) are configured like that.