View Full Version : Question CCS compiler serial command on 12f675
rocky79
Mar 26, 2008, 10:56 AM
Hi guys,
I am used to the serout command on the picbasic pro to output a serial command to a serial LCD display but now i am using the ccs compiler so i thought i would use the rs232 and the problem is it's not working, I am getting no signal at the Tx pin.
Here is my code:
#include <12f675.h>
#fuses INTRC_IO,NOWDT,NOPROTECT,NOMCLR
#use delay (internal=4000000) //(clock=4M)
#use rs232(baud=2400, xmit=PIN_A5, rcv=PIN_A3)
void main()
{
// First turn off the ADC on pinA
setup_adc(ADC_OFF);
//turn off all the analogs
setup_adc_ports (NO_ANALOGS);
while(1)
{
printf("%s\n","Hello");
delay_ms(1000);
}
}
Thanks
BushmanLA
Mar 26, 2008, 12:12 PM
Two things come to mind.
CCS may not be setting the TRIS register for you for the desired pin.
It should bit set to 0 for output.
CCS may default to an open collector type output. This means that the pin will pull the line down to 0 volts but will not push it up to 5 volts, instead of pushing 5 volts it goes into high impedance mode, you have to pull it up with a resistor (10k or so) to 5V.
In fact some pins on some pics are open collector hardware wise, and no matter what the software says, they cannot push 5V.
Oh, yeah, and make sure you understand the difference between hardware serial and software serial. I'm not sure how CCS works but you might be enabling one when you expect to be enabling the other.
BushmanLA
Mar 26, 2008, 12:24 PM
Just checked on some things.
The 12f675 has only one port and they reference the pins by GP0, GP1 etc, not the normal RA0, RB3, etc etc. Check the CCS stuff to see how the syntax should be.
GP stands for General purpose, RA stands for Register A, etc
None of the pins on the 12f675 are open collector, however pin GP3 is input only.
There is no hardware serial on this pic so make sure you are using the software serial routines with CCS (it looks like you are).
The internal RC oscillator on this pic runs at 4Mhz, I think you have it setup right but the old comment threw me off for a bit. Double check that the default speed is actually 4Mhz, the 12f683 that I use lets you actually change the osc speed on the fly in software.
rocky79
Mar 26, 2008, 01:44 PM
Just checked on some things.
The 12f675 has only one port and they reference the pins by GP0, GP1 etc, not the normal RA0, RB3, etc etc. Check the CCS stuff to see how the syntax should be.
GP stands for General purpose, RA stands for Register A, etc
None of the pins on the 12f675 are open collector, however pin GP3 is input only.
There is no hardware serial on this pic so make sure you are using the software serial routines with CCS (it looks like you are).
The internal RC oscillator on this pic runs at 4Mhz, I think you have it setup right but the old comment threw me off for a bit. Double check that the default speed is actually 4Mhz, the 12f683 that I use lets you actually change the osc speed on the fly in software.
Thanks BushmanLa for the reply. I am using GP5 and GP3. But GP3 is not important since i am not receiving anything from the lcd.
GP5 has an address of 45 and is defined in the .h file to be pin_A5.
you're right my comment should be 4mhz.
I will try to make Gp5 an output. but i thought the #use rs232
will do that for you.
rocky79
Mar 27, 2008, 03:08 AM
I am trying to drive the 4x20 LCD serial display from seetron (http://www.seetron.com/) by using the code above.
I got the signal on the output but the problem is I can't get the characters to display right.
Have anyone used the printf on a serial display before. Maybe an example would help.
Thanks
vBulletin® Copyright ©2000-2009, Jelsoft Enterprises Ltd.