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 in to a PC from a PIC 16F876 some time i get junk

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







RS232 in to a PC from a PIC 16F876 some time i get junk
PostPosted: Tue Mar 11, 2003 6:16 pm     Reply with quote

Hello All
I have search the board and have not found any thing on this so maybe it is a new thing (error) or just me or equipment.
I have a project that using the 16F876 that transmits a data frame on RS422 at 12500 baud.
Seeing as this is a nonstandard baud rate I build up a RS422 to RS232 converter using a 16F867 and RS422 chip and MAX232. (Code for this is below. CCS 3.147)

Now for the issue:
I’m using the RS232 utility that comes with CCS (siow.exe) to look at the incoming data from the converter.
The issues is that if I use my old IBM Thinkpad (Windows 98, 150 Pii) and siow.exe all of the data looks good no errors or what I would expect to see.
But if I use any other computer as in Acer TravelMate 739TLV (Windows XP Pro, 1Mhz Piii) or IBM Aptiva (Windows 98, 266 Pii) and siow.exe I get junk.
It is like the bits are shifted two bits.
I have tried all types of output baud rates and paritys.
I’m so confused!
Has any one run in to this?
Have you guys got any thoughts on this?
Any help on this would be gratefully appreciated.
Thank you all.



#include <16F876.h>
//#device CCSICD=TRUE, *=16
#fuses XT,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
//RS 232 output and input from PC
#use RS232(baud=57600, xmit=PIN_C6, rcv=PIN_C7, parity=o, stream=RS232)
//RS422 Input
#use RS232(baud=12500 ,rcv=PIN_C1, parity=o, bits=8, enable=pin_c0, stream=RS422)
#use fast_io(A)

#define HB_Low output_low(Pin_A5) //LED on pin 7 A5 output low
#define HB_High output_high(Pin_A5) //LED on pin 7 A5 output high

#define ints_per_ms 33 //The number of times that timer0 interrupts for 330ms heartbeat

int X1 = 0, C = 0;

static short int HBLED;
static int ms_count = ints_per_ms; //Set ms count for the 330ms heartbeat



#int_timer0
void heart_timer0() //This is the interrupt handler for the heartbeat
{
if ( --ms_count == 0 ) {
ms_count = ints_per_ms; //Reset the Ms counter for interrupt

if (HBLED == True) { //Test if Heartbeat LED is on
HB_Low; //Turns off HeartBeat LED
HBLED = False; //Set HBLED flag to false LED off
}
else { //Heartbeat LED is off
HB_High; //Turns on HeartBeat LED
HBLED = True; //Set HBLED true to false LED off
}
}
}




main() {
set_tris_a(0x00); //Set port a all bits to outputs for LED driver

setup_timer_0(RTCC_INTERNAL | RTCC_DIV_256 ); //Setup timer0 for button debounce
set_timer0(195); //Set timer0 for 10ms interrupt 9.984e-3 error for 10ms is 16us

enable_interrupts(GLOBAL); //Initialize all interrupts
enable_interrupts(INT_Timer0); //Turns On Timer0 interrupt for Heartbeat LED

output_a(0x00);

// output_low(PIN_c0);

while (TRUE) {
C=fgetc(RS422);
fputc(C,RS232);
C=0;

}//while (TRUE) loop
}//Main Loop
___________________________
This message was ported from CCS's old forum
Original Post ID: 12551
sar



Joined: 08 Sep 2003
Posts: 36

View user's profile Send private message

Re: RS232 in to a PC from a PIC 16F876 some time i get junk
PostPosted: Tue Mar 11, 2003 10:10 pm     Reply with quote

<font face="Courier New" size=-1>Hello Tom
Try this utility much better than CCS(siow.exe) and it's free.
<a href="http://bray.velenje.cx/avr/terminal/" TARGET="_blank"> <a href="http://bray.velenje.cx/avr/terminal/" TARGET="_blank">http://bray.velenje.cx/avr/terminal/</a></a></font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 12554
sar



Joined: 08 Sep 2003
Posts: 36

View user's profile Send private message

Re: RS232 in to a PC from a PIC 16F876 some time i get junk
PostPosted: Tue Mar 11, 2003 10:14 pm     Reply with quote

Hello Tom
Try this utility, better than CCS (siow.exe).
<a href="http://bray.velenje.cx/avr/terminal/" TARGET="_blank">http://bray.velenje.cx/avr/terminal/</a>
___________________________
This message was ported from CCS's old forum
Original Post ID: 12555
Thomas Hauff
Guest







Re: RS232 in to a PC from a PIC 16F876 some time i get junk
PostPosted: Wed Mar 12, 2003 7:34 am     Reply with quote

Thank You All
Late last night I did figure it out!
Apparently when I build up the converter board I forgot to solder in the ground wire on the PC 232 connector. Will if the RS232 signals are not referenced to ground who know what can be coming out of it.
One thing I did learn in all of this is that the baud rate that a person sets on a PC may not be the baud rate that you get.
References: Microsoft Knowledge Base Article – 99026 “INFO: Possible Serial Baud Rates on Various Machines”
All of this info is most likely old hat to all of you.
But it may help some one some day.

Thank All
___________________________
This message was ported from CCS's old forum
Original Post ID: 12562
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