View previous topic :: View next topic |
Author |
Message |
Ad01
Joined: 24 Jan 2008 Posts: 4
|
12F510 frustrations |
Posted: Thu Jan 24, 2008 4:03 pm |
|
|
Hi all,
I am trying to use a 12F510 to flash an LED once (PIN_B0 and PIN_B1) on start up before displaying Hello World to the computer terminal. Unfortunately these B0 and B1 pins never turn on no matter what I try (GP4 and GP5 do work) and the computer receives garbage characters. I have tried numerous modifications to the code below change baud rate, turn off AI comparators etc but cant seem to nail it can anyone help?
Code: | include <12F510.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC //Internal RC Osc
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOMCLR //Master Clear pin used for I/O
//#FUSES RB4 //B4 is an I/O pin not CLKOUT
#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_B5,rcv=PIN_B4,bits=8)
void main()
{
setup_comparator(NC_NC);
output_high(PIN_B0);
output_high(PIN_B1);
delay_ms(1000);
output_low(PIN_B0);
output_low(PIN_B1);
delay_ms(100);
while(1){
printf("Hello World");
}
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 24, 2008 4:10 pm |
|
|
1. Post your compiler version.
2. Post your connections to the PC's Com port connector.
Do you have a MAX232-type chip in the circuit ? |
|
|
Ad01
Joined: 24 Jan 2008 Posts: 4
|
|
Posted: Thu Jan 24, 2008 4:19 pm |
|
|
My compiler version is 4.057.
The RS232 connection to my computer i have tested with other 12F, 16F chips with no problems. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 24, 2008 4:47 pm |
|
|
The GP0 and GP1 pins are used for ICSP programming. Do you have
a programmer connected to the 12F510 while you are running the printf()
and the LED tests ? If so, disconnect it. |
|
|
Ad01
Joined: 24 Jan 2008 Posts: 4
|
|
Posted: Thu Jan 24, 2008 5:07 pm |
|
|
No, I have one breadboard for programming and another for circuit applications, totally isolated from one another. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 24, 2008 5:37 pm |
|
|
Quote: | #FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC //Internal RC Osc
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOMCLR //Master Clear pin used for I/O
|
In the 12F510, the internal oscillator frequency is set with a fuse
statement. If you don't specify it, the compiler defaults to 8 MHz.
That would explain why your RS-232 is garbled. Add this statement:
|
|
|
Ad01
Joined: 24 Jan 2008 Posts: 4
|
|
Posted: Thu Jan 24, 2008 5:50 pm |
|
|
Ok thanks PCM programmer ill give that a shot and let you know how I go. |
|
|
mongkol
Joined: 01 Aug 2010 Posts: 1 Location: THAILAND
|
|
Posted: Fri Jul 12, 2013 7:09 am |
|
|
Before to used I/O port you have to turn off analog port with setup_adc_ports(NO_ANALOGS). _________________ I'm MIKE |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Fri Jul 12, 2013 2:33 pm |
|
|
Yes. Mongkol is right. The _chip_ defaults to waking up with the ports all set as analog. On later compilers, the compiler automatically fixes this, but on an old compiler like this, you need to turn the analog off to use the port for normal I/O.
Best Wishes |
|
|
|