View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Feb 19, 2009 5:03 pm |
|
|
His original concept should work. The terminal program sends ASCII
numbers. Also, atoi() expects a string as a parameter. It doesn't accept
a char variable such as 'dado'.
My advice is to first prove that your communications work with the PC.
Try a simple program like this, in which the PIC receives a character
sent by the PC and then sends it back to the PC. You can type in
characters and see them on the terminal window. Be sure to disable
the option for "local echo" in the setup screen of your terminal program.
Then you won't see double characters.
Code: | #include <16F628A.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#use rs232(baud=9600, xmit=PIN_B2, rcv=PIN_B1, ERRORS)
//======================================
void main()
{
char c;
while(1)
{
c = getc();
putc(c);
}
} |
Also, let the compiler set the TRIS. It will do it automatically for you.
It will set pins to inputs or outputs as required by the peripheral device
(UART) or the CCS function that is used. You don't need the fast_io
and set_tris_x() statements. |
|
|
ECACE
Joined: 24 Jul 2006 Posts: 94
|
|
Posted: Thu Feb 19, 2009 5:26 pm |
|
|
OOPS! You're right. I was using a gets() in mine, not getc() like he is using.
Let's see the result of his test program.
I would suggest you try using the SIO program that comes with CCS. _________________ A HW Engineer 'trying' to do SW !!! Run!!! |
|
|
Blima
Joined: 13 Feb 2009 Posts: 3
|
|
Posted: Tue Feb 24, 2009 4:38 pm |
|
|
The program is now running thanks to your advice.
Regards,
Bruno |
|
|
|