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

12F510 frustrations

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



Joined: 24 Jan 2008
Posts: 4

View user's profile Send private message

12F510 frustrations
PostPosted: Thu Jan 24, 2008 4:03 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jan 24, 2008 4:10 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jan 24, 2008 4:19 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jan 24, 2008 4:47 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jan 24, 2008 5:07 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jan 24, 2008 5:37 pm     Reply with quote

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:
Code:
#FUSES IOSC4
Ad01



Joined: 24 Jan 2008
Posts: 4

View user's profile Send private message

PostPosted: Thu Jan 24, 2008 5:50 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jul 12, 2013 7:09 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jul 12, 2013 2:33 pm     Reply with quote

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