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

problem with RS232 in 12F675

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



Joined: 09 Aug 2007
Posts: 82
Location: TN, India

View user's profile Send private message Send e-mail

problem with RS232 in 12F675
PostPosted: Wed Mar 05, 2008 11:34 am     Reply with quote

hello..

i try to write the program to send the Hex command through PIC12F675, but i dont receive the any command from PIC...


my complier version is IDE - 3.41
PCB - 3.185
PCM -3.185
PCH - 3.185


Code:
#include <12F675.h>
#device adc=8
#use delay(clock=4000000)
#fuses NOWDT,INTRC_IO, CPD, PROTECT, NOMCLR, PUT, BROWNOUT
#byte OSCCAL=0x90
#define GP0 PIN_A0
#define GP1 PIN_A1
#define GP2 PIN_A2
#define GP3 PIN_A3
#define GP4 PIN_A4
#define GP5 PIN_A5
//========================
#use rs232(baud=9600,parity=N,xmit=PIN_A4,rcv=PIN_A5,bits=9)


#byte ADCON0 = 0x1F
#byte ANSEL = 0x9F
#byte CMCON = 0x19

#rom 0x3ff = {0x3470} // input the calibration code
void main()
{

ADCON0 = 0; // ADC off
ANSEL = 0; // GPIO pins 0,1,2 and 4 set to all digital
CMCON = 7; // Comparators off
set_tris_a(0b100000);
delay_ms(1000);
putc(0X7E);
putc(0X07);
putc(0XA0);
putc(0X30);
putc(0X30);
putc(0X30);
putc(0X30);
putc(0X30);
putc(0X7E);

while(1) {



    }

}



please check the code and give solution...
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 05, 2008 12:21 pm     Reply with quote

Why are you using 9 bits ? Standard RS-232 is 8 bits. You don't need
to specify 8 bits in the #use rs232() statement. It's the default value.

Are you using a MAX232 chip ?

See these two threads for more help.
http://www.ccsinfo.com/forum/viewtopic.php?t=32751
http://www.ccsinfo.com/forum/viewtopic.php?t=28067
Guest








PostPosted: Wed Mar 05, 2008 3:52 pm     Reply with quote

no, I am using 8 bit, it goes through MAX485,
but the problem arises only with a 20MHz crystal,
it works perfectly with a 10MHz crystal.

So the only logical conclusion is the baud rate generator.

The core is: how to set the baud rate generator manually?
Why it doesn't work, and why the IDE shows 0 for the register
involved and manually set?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 05, 2008 4:04 pm     Reply with quote

There is no baud rate generator in a 12F675. It doesn't have a UART.
It's all done with software polling loops and delays, in the CCS library code.
Ttelmah
Guest







PostPosted: Wed Mar 05, 2008 4:57 pm     Reply with quote

And (of course), _requires_ that you set the #use delay, to match the frequency the chip is actually running. You talk about using 10MHz, and 20MHz, but the code shown, is for 4Mhz. Remember also the HS fuse. I have seen chips run at 10MHz, with XT selected, but then fail when trying to go faster. What voltage is the power supply?. 20Mhz, requires at least 4.5v.

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