|
|
View previous topic :: View next topic |
Author |
Message |
karthickiw
Joined: 09 Aug 2007 Posts: 82 Location: TN, India
|
problem with RS232 in 12F675 |
Posted: Wed Mar 05, 2008 11:34 am |
|
|
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
|
|
|
Guest
|
|
Posted: Wed Mar 05, 2008 3:52 pm |
|
|
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
|
|
Posted: Wed Mar 05, 2008 4:04 pm |
|
|
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
|
|
Posted: Wed Mar 05, 2008 4:57 pm |
|
|
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 |
|
|
|
|
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
|