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

16F88 RS232 Error

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



Joined: 24 Nov 2005
Posts: 7

View user's profile Send private message

16F88 RS232 Error
PostPosted: Fri May 05, 2006 9:51 am     Reply with quote

Hi All

Please can you help me

I have a 16F88 with a Timer driven software serial routine

my code is a follows

Code:


#use rs232(baud=9600,parity=N,xmit=PIN_B4,rcv=PIN_B1,bits=8,stream=RADIO2)

#int_TIMER2 // Radio 2 Ping Pong Buffer
void TIMER2_isr()
{
   if (kbhit(Radio2))
   {
      Radio2Char=fgetc(Radio2);
         radio2_flag_bufferfull=1;
}

setup_timer_2(T2_DIV_BY_1,4,10);

if (Radio2_flag_bufferfull==1)
         {
            radio2_flag_bufferfull=0;
            fprintf(Radio2, "%d", Radio2Char);
}




But all i get from the serial port is bad data

for example if i send a K i get 25 chars rx from the pic?????

If i disable the Timer2 the TX of the serial all works ok

I have the same code running on a 16F876A with no problems

Please help

Colin
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Fri May 05, 2006 10:36 am     Reply with quote

Pls could you tell us whatīs the reason to expect a char just arriving inside the #int_TIMER2 "time window" ?

Why you didnīt use the built-in hardware UART ?

baud=9600,parity=N,xmit=PIN_B5,rcv=PIN_B2


Humberto
colin_turner99



Joined: 24 Nov 2005
Posts: 7

View user's profile Send private message

PostPosted: Sat May 06, 2006 10:37 am     Reply with quote

Hi I am also using the Hardware port for RS232 as well

The window should be the time for 1 char to be sent at 9600

The code works on a 16F876A with no problems

Colin
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Sat May 06, 2006 1:58 pm     Reply with quote

Your code shows that you are trying to receive a char at regular intervals, not to transmit. To do it in such way you should synchronize the timer with an event coming from the transmitter or use the edge detecting capabilities of the INT_EXT module.
For a software UART you should use kbhit() prior to getc() to test if a char is arriving.


Humberto
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