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

16F1947 RS232 Can't Receive Data

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



Joined: 09 May 2011
Posts: 6

View user's profile Send private message

16F1947 RS232 Can't Receive Data
PostPosted: Wed May 11, 2011 9:55 pm     Reply with quote

The following code is the master send data to the slave. I think the master has sent the data to slave, but the slave can not receive any data from master.

My Hardware Design: xmit=PIN_G1, rcv=PIN_G2. I am Using TX2 and RX2.

Master Code:
include <16F1947.H>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT
#Fuses INTRC_IO
#use delay(clock=32000000)
#use rs232(baud=9600, xmit=PIN_G1, rcv=PIN_G2, bits=8)

void main()
{
output_bit(PIN_G0,0);
while(1)
{
output_high(Pin_G0);
putc(1);
delay_us(10);
}
}


Slave Code:
include <16F1947.H>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT
#Fuses INTRC_IO
#use delay(clock=32000000)
#use rs232(baud=9600, xmit=PIN_G1, rcv=PIN_G2, bits=8)

int test_1=3;

#byte RC2STA = 0x495
#byte TX2STA = 0x496
#bit OERR = RC2STA.1
#bit FERR = RC2STA.2
#bit SPEN = RC2STA.7
#bit CREN = RC2STA.4
#bit TXEN = TX2STA.5
#byte PIE1 = 0x91
#bit RCIE = PIE1.5
#bit TXIE = PIE1.4

#int_RDA
void RDA_isr(void)
{
if( kbhit() )
{
output_bit(PIN_G0,0);
test_1 = getc();
delay_us(20);
}
}

void main()
{
output_bit(PIN_G0,0);
while(1)
{}
}




Thanks for your help !!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 11, 2011 10:30 pm     Reply with quote

You don't need to start a new thread for each new test of the rs232 with
the 16F1947. You already have a thread on it here:
http://www.ccsinfo.com/forum/viewtopic.php?t=45393

Just add new rs232 questions to that existing thread.
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