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

16F676 rs232 not working

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



Joined: 31 Dec 2011
Posts: 5
Location: Baripada

View user's profile Send private message Visit poster's website

16F676 rs232 not working
PostPosted: Wed Jun 13, 2012 12:42 am     Reply with quote

I am using internal oscillator. I already try it on many more projects. When I am trying to communicate with pc no data show. What I doing wrong ?
Code:

#include <16F676.h>
#fuses INTRC_IO,NOWDT,NOPROTECT,NOMCLR
#use delay (clock=4000000)  // 4MHz clock
#use rs232(baud=9600, xmit=PIN_C2, rcv=PIN_C1)

void main()
{

while(1)
  {
   printf("working"); // for show on pc
   delay_ms(1000);
  }

}
Ttelmah



Joined: 11 Mar 2010
Posts: 19260

View user's profile Send private message

PostPosted: Wed Jun 13, 2012 1:15 am     Reply with quote

What hardware are you using to connect to the PC?. You do realise you need an RS232 transceiver between the PIC and the PC?.
Have you verified the chip is actually running (add 'output_toggle', some unused pin, after the delay), and verify that the pin does toggle just over every second. On these chips, the internal oscillator will not work, if you have done a full erase, without saving the factory clock calibration (most programmers have an option to do this).
The clock accuracy of the internal RC, can be 'borderline' for RS232, which can give character corruption, but 99% of the time it'll work, and even if the clock is too far out, you will see something.

Best Wishes
souravkumarkar



Joined: 31 Dec 2011
Posts: 5
Location: Baripada

View user's profile Send private message Visit poster's website

PostPosted: Mon Jun 18, 2012 2:16 am     Reply with quote

Tnxs sir.
After you reply I'm trying crystal oscillation. I use fuse HS for 20MHz. Also same problem as internal oscillation. No response from pc. I try same code in 16f877a and its work. Have any recommended pin in 16f676 is used as rs232 protocols.
Ttelmah



Joined: 11 Mar 2010
Posts: 19260

View user's profile Send private message

PostPosted: Mon Jun 18, 2012 3:24 am     Reply with quote

The hardware UART, is always 'better', since it allows you to do other jobs while characters are sending/receiving. However your chip doesn't have one, so it makes no difference what pins are used (excluding hardware restrictions, such as A3, only supporting input).
Have you actually tested you can toggle a pin. _Forget_ RS232, until you have proved the chip is running, and running at the right speed. It is like trying to test the towball on a car, without having first made sure the engine works....
You say you have tried the same code on an 877a, but this is a 40pin device, with a UART, while the 676, is only a 14pin device, so your hardware is different. +5v on pin1?. 0v on pin14?. etc. etc...

Best Wishes
souravkumarkar



Joined: 31 Dec 2011
Posts: 5
Location: Baripada

View user's profile Send private message Visit poster's website

PostPosted: Sun Jun 24, 2012 8:12 am     Reply with quote

Thanks you very much sir.
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