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

RS232

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



Joined: 10 Sep 2003
Posts: 60

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger ICQ Number

RS232
PostPosted: Fri May 06, 2005 4:11 am     Reply with quote

Dear all,

I try to transfer RS232 data from the computer to PIC16f876. In the computer, I am using Visual C WriteFile Function. In the PIC16f876, I use an interrupt to check for data. If the first byte sent is 2 (ID), the following byte will be received. However, I noticed that only the first byte is received instead. May I know how should I solve this problem?

#include <16f876.h>
#fuses hs,NOPROTECT,NOLVP,PUT,BROWNOUT,NOWDT
#use delay(clock=20000000)
#use rs232(baud=115200,xmit=PIN_C6,rcv=PIN_C7,PARITY=N)

#include <lcd.c>

#byte PORTA=5
#byte PORTB=6
#byte PORTC=7

byte status=0;
byte smain=0;

#int_rda
void serial_isr()
{
a=getc();

if(a==2 && status==0)
{
status=1;
}

else if(status==1)
{
status=0;
smain=1;
}
}

void main()
{
set_tris_a(0);
setup_port_a(no_analogs);
set_tris_b(0);
set_tris_c(0x85);

lcd_init();

enable_interrupts(int_rda);
enable_interrupts(global);

do
{
if(smain==1)
{
if(a==18)
{
lcd_putc("\f GRAB");
}

else if(a==14)
{
lcd_putc("\f LED 1");
}

}while(1);
}
_________________
Einly
yanickch



Joined: 02 May 2005
Posts: 1

View user's profile Send private message

RS232
PostPosted: Fri May 06, 2005 7:34 am     Reply with quote

Hi,

do
{
if(smain==1)
{
if(a==18)
{
lcd_putc("\f GRAB");
}

else if(a==14)
{
lcd_putc("\f LED 1");
}


} <---------- you need that here

}while(1);
}


bye Yanickch
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