|
|
View previous topic :: View next topic |
Author |
Message |
pattousai
Joined: 23 Aug 2006 Posts: 37
|
one more serial problem - getc() doesn't work |
Posted: Wed Nov 15, 2006 3:19 pm |
|
|
hi everybody, sorry for the bothering over such a discussed subject
but, i'm trying to make a connection pic-pc
i can send a message from the pic to the pc, but when i try to get a character from the pc to the pic it just doesn't work.
here is one of my code
Code: |
#include <16F877a.h>
#fuses XT,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, parity=N, xmit=PIN_b6, rcv=PIN_b7, bits=8, invert) // Jumpers: 8 to 11, 7 to 12
void main() {
char x;
printf("\r\n-----LIGADO-----");
while(TRUE){
if( kbhit() ){
x = getc();
delay_ms(100);
putc(x);
}
}
}
|
i already try to send only one chatacter with putc('a'), and works fine
i think that's it.
hope that anyone can help me!!
thanks, and sorry for the bad english |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Nov 15, 2006 3:37 pm |
|
|
See this post regarding the use of a series resistor when using INVERT.
http://www.ccsinfo.com/forum/viewtopic.php?t=26592&highlight=invert+resistor&start=10
Also, your program will work if you are slowly typing characters on
your PC keyboard. But if you send a message to the PIC with no
spacing between the characters, the 100 ms delay in your program
will cause the PIC to miss characters. |
|
|
BOB_SANTANA
Joined: 16 Oct 2006 Posts: 110 Location: HOVE, EAST SUSSEX
|
|
Posted: Wed Nov 15, 2006 3:39 pm |
|
|
just ran your code and it works but i am using hardware uart as below
#if defined(__PCM__)
#include <16F877.h>
#ORG 0x1F00,0x1FFF {} // use boot loader for the 8k 16F877
#fuses XT,NOWDT,NOPROTECT,BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7,ERRORS) // _________________ BOB_Santana |
|
|
pattousai
Joined: 23 Aug 2006 Posts: 37
|
|
Posted: Thu Nov 16, 2006 7:41 am |
|
|
i miss the
Code: | #ORG 0x1F00,0x1FFF {} // use boot loader for the 8k 16F877 |
part, why is that??
and, when i try tu use the uart, i can't even send messages to the pc. when i try to do that what i have is garbage.
i use the max232 IC, with the configuration just like is this topic:
http://www.ccsinfo.com/forum/viewtopic.php?t=25905
as for the resistor, i will try that.
thanks to everybody |
|
|
Ttelmah Guest
|
|
Posted: Thu Nov 16, 2006 8:23 am |
|
|
With the MAX232, get rid of the 'INVERT' keyword. The MAX232, contains the required hardware inverter.
Best Wishes |
|
|
pattousai
Joined: 23 Aug 2006 Posts: 37
|
|
Posted: Fri Nov 17, 2006 9:20 am |
|
|
Ttelmah wrote: | With the MAX232, get rid of the 'INVERT' keyword. The MAX232, contains the required hardware inverter.
Best Wishes |
exactly, but when i do that i'm getting only garbage
that's why i'm don't using the uart |
|
|
|
|
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
|