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 support@ccsinfo.com

#INT_RDA

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







#INT_RDA
PostPosted: Tue Sep 20, 2005 12:10 am     Reply with quote

Would somebody suggest why this code wont work, cuz it aint?
Im printing a character upon a serial interrupt

Code:
********************************

#include <16F877a.h>
#device *=16
#include<stdlib.h>
#fuses XT,NOWDT,NOLVP
#use delay (clock=4000000)
#use rs232(baud=4800,xmit=PIN_A1,rcv=PIN_B1,parity=N)

char ch;
int i;

#INT_RDA
void serial_isr()
{
putc('a');
}


void main()
{
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);

while(1)
{
delay_ms(333);
}
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 20, 2005 12:26 am     Reply with quote

#int_rda only works with the hardware UART.
If you move your RS-232 to pins C6 and C7, then you can use it.
Example:
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
GQ
Guest







Re: #INT_RDA
PostPosted: Tue Sep 20, 2005 1:38 am     Reply with quote

Thanx,programs working. but it continously prints 'a' once a key is pressed. That means the key acts as just another key triggering the isr. Since it keeps on printing 'a' without getting out of the isr(no delay of while loop), it also means the isr interrupt flag bit is not going low. Am i right?

*****************
Code:

#include <16F877a.h>
#device *=16
#include<stdlib.h>
#fuses XT,NOWDT,NOLVP
#use delay (clock=4000000)
//#use rs232(baud=4800,xmit=PIN_A1,rcv=PIN_B1,parity=N)
#use rs232(baud=4800, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
char ch;
int i;

#INT_RDA
void serial_isr()
{
/*
ch=getc();
if(ch=='A')
putc('a');
else if(ch=='B')
putc('b');
else
putc('E');
*/

putc('a');
}


void main()
{
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);

while(1)
{
delay_ms(1000);
}
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 20, 2005 1:45 am     Reply with quote

You must actually 'get' the character while inside the isr. Do this with
the getc() function. You have it commented out.
GQ
Guest







PostPosted: Tue Sep 20, 2005 3:14 am     Reply with quote

thanx
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