CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

RS232 receive interrupt issue

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mutthunaveen



Joined: 08 Apr 2009
Posts: 100
Location: Chennai, India

View user's profile Send private message

RS232 receive interrupt issue
PostPosted: Sun Aug 24, 2014 8:58 am     Reply with quote

hello board

im getting a wired error on INT_RDA, without any action on rx tx from my serial port in my computer im receiving a interrupt all the time

in my computer im reading "received some data" all the time (even i did not send any data to PIC)

here is my code
Code:
#include <16F877a.h>
#device adc=10
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#include <flex_lcd.c>

#int_RDA
void  RDA_isr(void)
{
   printf("\n\r some data received \n\r");
}

void main()
{

   printf("\n\r program initiated \n\r");

   enable_interrupts(INT_RDA);
   enable_interrupts(GLOBAL);
   
while(1){
   
   delay_ms(1000);
   
}
}
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Aug 24, 2014 9:01 am     Reply with quote

ASSUMING this is REAL hardware and NOT a 'simulation'.....
Do you have a MAX232 or equal between the PIC and PC ?

Also, you should NOT be printing 'inside' the ISR. Instead, set a flag within the ISR and in main check to see if set.


hth
jay
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Sun Aug 24, 2014 9:42 am     Reply with quote

Hi,

This has been covered hundreds of times before. You MUST actually read the received character inside the ISR to clear the int rda interrupt. Add the following to your ISR:

Code:

Char Temp;
Temp=getc();


John
Ttelmah



Joined: 11 Mar 2010
Posts: 19548

View user's profile Send private message

PostPosted: Mon Aug 25, 2014 2:49 am     Reply with quote

As Ezflyr says, has been covered multiple times.

However I'll just expand a fraction further.

Key is to understand 'what' the interrupt says.

INT_RDA, is triggered when 'there is a character waiting to be read'.

Now you can clear INT_RDA fine, (the compiler does this for you, when you exit the handler), but since there is still a 'character waiting to be read', it will set again immediately (actually at the start of the instruction after the clear).

You need to distinguish between interrupts that happen at a 'moment', like 'INT_EXT', which occurs when the input signal 'moves through a particular level' (high to low, or low to high), and interrupts that are triggered by a condition or mis-match (INT_RDA, INT_RB, INT_TBE etc..). The latter, require the condition/mis-match to be 'handled' before they are cleared, or they will trigger again, until this is dealt with....

So for INT_RDA, you have to read the byte waiting. For INT_RB, you need to read/write the port, to reset the latches here, for INT_TBE, you need to load a byte into the transmit buffer, etc. etc..

It is in the data sheet, for the peripherals concerned.
mutthunaveen



Joined: 08 Apr 2009
Posts: 100
Location: Chennai, India

View user's profile Send private message

thanks for your help board
PostPosted: Mon Aug 25, 2014 10:14 pm     Reply with quote

thanks guys...
yes i have MAX IC and now it work Wink
the mistake i made is -> the answer given by ezflyr (thanks man Smile )

thank you Ttelmah for your elaborated information......

now everything works great Very Happy Very Happy

it will be good if they add this information in HELP file of CCS Idea
Ttelmah



Joined: 11 Mar 2010
Posts: 19548

View user's profile Send private message

PostPosted: Tue Aug 26, 2014 12:12 am     Reply with quote

Not really. CCS, expect you to understand the hardware. It's not their job to explain things in this.
mutthunaveen



Joined: 08 Apr 2009
Posts: 100
Location: Chennai, India

View user's profile Send private message

yes indeed
PostPosted: Tue Aug 26, 2014 10:04 am     Reply with quote

yeah... you are totally correct... its not CCS job.....

CCS would sure help for low hardware knowledge people (like me)
megaball



Joined: 04 Oct 2018
Posts: 1

View user's profile Send private message

PostPosted: Wed Sep 25, 2019 5:39 am     Reply with quote

HI,

Can you post all your program?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group