Author Topic: PIC18 F... interrrupt on RB0  (Read 2396 times)

0 Members and 1 Guest are viewing this topic.

Offline Spock

  • Contributor
  • Posts: 8
  • Country: pl
PIC18 F... interrrupt on RB0
« 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:
Code: [Select]
    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.

 

Offline Rufus

  • Super Contributor
  • ***
  • Posts: 2094
Re: PIC18 F... interrrupt on RB0
« Reply #1 on: September 29, 2013, 10:35:53 pm »
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.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: PIC18 F... interrrupt on RB0
« Reply #2 on: September 29, 2013, 10:44:45 pm »
Quote
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.
================================
https://dannyelectronics.wordpress.com/
 

Offline Spock

  • Contributor
  • Posts: 8
  • Country: pl
Re: PIC18 F... interrrupt on RB0
« Reply #3 on: September 30, 2013, 09:22:55 am »
@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 ..

 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: PIC18 F... interrrupt on RB0
« Reply #4 on: September 30, 2013, 10:31:08 am »
Quote
check datascheet where is it written with * on bottom of one pages :/

All the PICs (low-end) are configured like that.
================================
https://dannyelectronics.wordpress.com/
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf