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 support@ccsinfo.com

PIC 16F767 rs232 Read Problems

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



Joined: 08 Mar 2005
Posts: 2

View user's profile Send private message

PIC 16F767 rs232 Read Problems
PostPosted: Tue Mar 08, 2005 3:00 pm     Reply with quote

Hi I'm having the hardest time getting my 16F767 to properly read over the rs232 port. It reads in 1 character then puts out a whole bunch of garbage characters and then freezes.

Perhaps I'm missing something important in the set-up? Perhaps the compiler version isn't generating thr correct rs232 code??? (How do I check?)
Thanks! chipp

Using Hardware USART at 9600.
Using 20Mhz Ceramic Resonator as Clock.

Compiler: PCM 3.212

Code:

#include <16F767.h>
#use delay(clock=20000000)

// This is CCS's setup
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, parity=N, bits=8, brgh1ok)

void main() {
   char c;
   
   set_tris_a(0x00000000;
   set_tris_b(0x00000000);
   set_tris_c(0x10000000); // C7 rx, C6 tx

   SETUP_ADC(ADC_OFF);
   SETUP_ADC_PORTS(NO_ANALOGS);


   while(TRUE) {

      if(kbhit()) {
         c = getc();
         delay_ms(1);
         putc(c);
         delay_ms(1);
      }
   }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 08, 2005 3:19 pm     Reply with quote

Try a more simple test program, and also include a #fuses statement.
Try sending characters to the PIC by typing in a terminal program.
You should see them echo'ed back to the terminal.
Code:
#include <16F767.h>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

void main()
{
char c;

while(1)
  {
   c = getc();
   putc(c);
  }
}
 


Note that this PIC doesn't support Low Voltage Programming, so the
LVP and NOLVP fuses are not an issue here.
chipp



Joined: 08 Mar 2005
Posts: 2

View user's profile Send private message

It Works!
PostPosted: Thu Mar 10, 2005 11:46 am     Reply with quote

Thank you, simple as it is it works, it seems like setting the TRIS on Port C was somehow interferring, so I commented it out:

Code:

//    set_tris_c(0x10000000); // C7 rx, C6 tx

fuzzy



Joined: 26 Feb 2005
Posts: 64

View user's profile Send private message

PostPosted: Thu Mar 10, 2005 2:54 pm     Reply with quote

I had a similar problem, my pic received all what he transmitted!!

I solved setting in a correct way TrisC.

in your case 0x10000000 is a hexadecimal number not a binary one.

tri to set 0b10000000 or 0x80 in TRISC
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