Continue to Site

Welcome to

Welcome to our site! 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.

[PIC] RBIF triggered for UART Interrupts.

Not open for further replies.


Junior Member level 1
Feb 21, 2007
Reaction score
Trophy points
Activity points
Hi All,

I am doing a project using the SIM 900 and PIC16F877A. I am able to read the UART and send through UART as well. I am having ISR code which has 2 blocks,one handles the UART interrupt to store the serial data ,and another check for the RB0 interrupt.

I have enabled the INTE,GIE, RCIE=1 and PEIE=1;TRISB0=1, and TRISB1=0.

void interrupt ISR(void) {
    if (RCIE && RCIF) {
    if (INTF) {
        INTF = 0;
        INTE = 0;
        RB1 = ~RB1;  -// to toggle an LED connected.
        sendSMS();  // Send an SMS.

When the RB0 is connected to a switch using the pullup and when the switch is closed the interrupt is working and the LED is toggling .
When I send an SMS to this number ,UART is working fine as it displays everything from the SMS and nothing is happening to LED .. Looks OK.

When this RB0 is connected to the O/P of a PIR sensor(movement detection), and when movement noticed the LED toggles. This also works fine and interrupt works for INTF.

I have tested these with PIC16f877A in proteus with 20MHz and is working fine whereas in real time it is not working.

But the problem occurs when the RB0 is still connected to the PIR o/p, and when I send an SMS to this SIM900 module, the interrupt is happening for the LED as well. I am not sure how this INTF is getting triggered on the UART input/interrupt or when the RCIF is set.

I have tried many options of checking whether INTF and RB0=1 so as to disable the interrupt call to toggle the LED. But that also fails.

Is it like the INTF is always set when the RCIF is set or someother cases ?
Can someone help me with the problem ?

Rahul M R

You cannot have a long lasting function inside the interrupt service routine.

What these USARTHandleRxInt() and sendSMS(); will do is to just set the flags and in the main while loop only the other actions are performed.
My main issue is that when the RCIF is triggered for serial input, the INTF is also triggered and calls the SendSMS().

This happens only when I connect the o/p of PIR sensor to the RB0, and when PIC recevie an input on the Rx (C5) of the PIC which is set as the usart Rx for the PIC.

But this INTF is not set or the sendSMS is not called from the ISR when the RB0 is connected to a switch .Even when the Rx(C5) of the PIC receives an input, the INTF is not set that time . I can confirm because at this time the LED is not toggled.

Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to