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 CCS Technical Support

one more serial problem - getc() doesn't work

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



Joined: 23 Aug 2006
Posts: 37

View user's profile Send private message

one more serial problem - getc() doesn't work
PostPosted: Wed Nov 15, 2006 3:19 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Nov 15, 2006 3:37 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Nov 15, 2006 3:39 pm     Reply with quote

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 Smile
pattousai



Joined: 23 Aug 2006
Posts: 37

View user's profile Send private message

PostPosted: Thu Nov 16, 2006 7:41 am     Reply with quote

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







PostPosted: Thu Nov 16, 2006 8:23 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Nov 17, 2006 9:20 am     Reply with quote

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
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