Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

UART RX interrupt is not working(PIC18f24j11)

Status
Not open for further replies.
The problem was a mix of register names and configuring interrupts but then polling the interrupt flag to see if data was available instead of doing it in the ISR.

There is a modification you can try which might overcome a problem if something else slows the ISR down:

Instead of using "if(DataRdy1USART()" to see if the USART holds data, use "if(PIR1bits.RC1IF == 1)" instead. You already know something triggered the interrupt because you have entered the ISR but if you expand your code so the ISR is used to service other interrupts as well, you need to be able to distinguish one source from the other. The interrupt flags are the best way to do that. In your code, you know the USART is 'ready' already because you would not have reached that place in code if it wasn't.

A better ISR structure would be like this (pseudo coded):
Code:
void interrupt ISR()
{
    if(interrupt flag xxx == 1)
    {
        do the xxx service routines
        clear xxx flag
    }
    
    if(interrupt flag yyy == 1)
    { 
        do the yyy service routines
        clear yyy flag
    }

    if(interrupt flag zzz == 1)
    {
        do the zzz service routines
        clear zzz flag
    }
} // end of ISR

Brian.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top