|
|
View previous topic :: View next topic |
Author |
Message |
young
Joined: 24 Jun 2004 Posts: 285
|
RS232 mess communication |
Posted: Wed Sep 22, 2004 9:59 am |
|
|
I am using a software RS232 communication on 16f819, the program is down here:
Code: |
#if defined(__PCM__)
#include <16F819.h>
#fuses INTRC_IO,NOWDT,NOPROTECT,NOLVP
#use delay(clock=8000000)
#use rs232(baud=9600, parity=N, xmit=PIN_A0, rcv=PIN_A1)
void main()
{
// printf("start1!");
puts("Start2!");
while(1) {
while(getc()=='a')
delay_us(5);
{
// putc('B');
puts("what happened!");
// output_low(PIN_A0);
}
}
}
|
what I saw in the hyperterminal is something strange like this
Quote: |
\0Aat há𕹕‘…\0DD
áwhat èáÁeneäHCáwhat happeîYVj\0AD0D
what happeîYVj\0A
áwhat happåîYVj\0A wèáB…ÁÁ•¹•‘…\0D
áwhat happened!\0Dhat happened!\0DD |
I trieed B6, B7; B4,B5; also as TXD and RCV, all I got is similiar like the above, what is wrong with my program? |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Wed Sep 22, 2004 3:18 pm |
|
|
A couple of possibilities come to mind. 1. There is something wrong with the voltage levels coming from your level converter. If using a MAX232 type device, check for presence of +9 and -9 volt levels (approx) at the V+ and V- terminals. Alternative 2, there is a bit timing problem - are you using a crystal? |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Sep 22, 2004 4:40 pm |
|
|
Sometimes the text 'what happened' comes trough OK, to me this means your baudrate and electronics are most likely alright. What I think is very strange are the '\0A' and '\0D' sequences, these are the CR and LF characters added by the puts() function but normally you wouldn't see them on the screen like this. My guess is your Hyperterm is configured for emulating some weird kind of terminal instead of the default ANSI terminal emulation. Check the setting for emulation settings under File/Properties of Hyperterm.
By the way, Hyperterm is a terrible program for serial communication, it has caused me a lot of troubles in many different ways. |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Wed Sep 22, 2004 4:58 pm |
|
|
Quote: |
#fuses INTRC_IO,NOWDT,NOPROTECT,NOLVP
#use delay(clock=8000000)
|
If you are using a Xtal oscillator it should be
Code: |
#fuses XT,NOWDT,NOPROTECT,NOLVP
#use delay(clock=8000000)
|
If you are using the internal oscillator, the frequency
should be defined with setup_oscillator() function
OSC_8MHZ in your case.
Hope this help
Humberto |
|
|
|
|
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
|