interrupt only happens 4 times on dspic30f

Discussion in 'Embedded Systems and Microcontrollers' started by bassplayer142, May 16, 2010.

  1. bassplayer142

    Thread Starter Active Member

    Jan 2, 2007
    89
    0
    I have an interrupt for the uart rx that swtiches a led and increments a value sent our over serial. The interrupt only happens 4 times though and then after awhile the whole thing resets back to 0 and the interrupt starts working again. I have no idea why and any help would be great. below is my initialization code and the output over uart.

    (data.c)

    void initsci1(void){
    U1MODE = 0x8000;
    U1STA = 0x0400;
    U1BRG = 48;
    delay(100);
    IPC2bits.U1TXIP = 4;
    IPC2bits.U1RXIP = 3;

    IFS0bits.U1TXIF =0; //clear timer1 interrupt flag
    IFS0bits.U1RXIF =0; //clear timer1 interrupt
    IEC0bits.U1TXIE=0; //disable timer1 Interrupt
    IEC0bits.U1RXIE=1; //enable timer1 Interrupt

    }

    /////////////////////////////////////////////////////////////////////////////
    (interrupts.c)
    unsigned char val = 0;

    void _ISR _U1RXInterrupt(){

    val++;
    sendchar1(val);
    LATB = ~PORTB;
    IFS0bits.U1RXIF=0;
    }

    It may be important to note that these are in different c files considering that val gets sent back to 0 but is outside of the interrupt. They are both being called from main.c as follows

    #include "data.c"
    #include "interrupts.c"

    TX: DF
    RX: 01
    TX: DF
    RX: 02
    TX: DF
    RX: 03
    TX: DF
    RX: 04
    TX: DF
    TX: DF


    Thanks for any help.
     
    Last edited: May 16, 2010
  2. bassplayer142

    Thread Starter Active Member

    Jan 2, 2007
    89
    0
    Fixed my problem, an op can delete this if you would like.
     
  3. bertus

    Administrator

    Apr 5, 2008
    15,648
    2,348
    Hello,

    What was the solution?
    Others might have intrest too.

    Bertus
     
  4. bassplayer142

    Thread Starter Active Member

    Jan 2, 2007
    89
    0
    Quite simply, I wasn't requesting the data with a inchar function and storing it in a dummy variable. I guess after 4 times it just stops due to the buffer or something.
     
  5. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    Ahh... once the buffer is full, no more interrupts. Thats good to know.
     
Loading...