View previous topic :: View next topic |
Author |
Message |
Grkan13
Joined: 06 Apr 2011 Posts: 14
|
Serial Port monitor, taking wrong characters |
Posted: Wed Apr 06, 2011 9:01 am |
|
|
Hello,
I'm trying to send some simple printf commands, but there is something wrong about settings i think.
here is my code:
Code: |
#include <16F877.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES xt
#FUSES NOPUT //No Power Up Timer
#FUSES PROTECT //Code protected from reads
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
void main()
{
printf("Hello World, please");
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
while(TRUE)
} |
I see on the screen " Nenno>Wornf, *neyse"
When i try to send " battery" i saw rottery and it was changing. sometime "bottery" and sometimes "battery" |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Wed Apr 06, 2011 9:34 am |
|
|
Have you got a good earth connection?.
What is generating you processor clock.
Best Wishes |
|
|
Grkan13
Joined: 06 Apr 2011 Posts: 14
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Wed Apr 06, 2011 10:01 am |
|
|
What is the PCB layout round the crystals, what loading capacitance are they meant to have, what capacitors were you using?. Your link gives no details of how you are linking the serial ground, which is what 'matters' for the communication.
Your fault is classic for a connection not having both wires for the connection (the data line and the ground), properly connected, or the USART clock is unreliable.
Also what are you using for the level translation on the connection?.
Best Wishes |
|
|
Grkan13
Joined: 06 Apr 2011 Posts: 14
|
|
Posted: Wed Apr 06, 2011 10:57 am |
|
|
I'm using a breadboard. My capacitors for the crystals are 22pf ceramic.
There are 5 pins on the power connector, +5V, GND, +24V, -12V, +12V. I've just connected the +5V and +12V to the my breadboard with a cable.
Hmm I think the problem is not connecting properly on the rs-232 connector, I will try to change it. Because when I order they send me wrong connector, I have a female without pins. Male connector's pins and my data and ground cables are just touching each other in holes. |
|
|
|