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.

[PIC] RBIF triggered for UART Interrupts.

Status
Not open for further replies.

rahulmr

Junior Member level 1
Joined
Feb 21, 2007
Messages
16
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,434
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.

Code:
void interrupt ISR(void) {
    if (RCIE && RCIF) {
        USARTHandleRxInt();
        return;
    }
    if (INTF) {
        INTF = 0;
        INTE = 0;
        RB1 = ~RB1;  -// to toggle an LED connected.
        __delay_ms(3000);
        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 ?

Thanks,
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.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top