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 support@ccsinfo.com

12F683 questions, internal osc. and pullups

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



Joined: 20 Oct 2005
Posts: 44

View user's profile Send private message

12F683 questions, internal osc. and pullups
PostPosted: Thu Oct 20, 2005 10:13 am     Reply with quote

Hello. I'm doing a simple project with a 12F683 and I'm having a few issues. Compiler is 3.203. First off, let me make sure I have my pin definitions correct.

Code:

PIC     Ccs

GP0     PIN_A0
GP1     PIN_A1
GP2     PIN_A2
GP3     PIN_A3
GP4     PIN_A4
GP5     PIN_A5


1st problem is with the internal oscillator. I first tried INTRC_IO then INTRC, no luck. For some reason it only seems to work when I use RC.

Second issue is pullups. I have switches connected to pins 2 and 3 (GP4 and 5, which the DS says have individually programmable pullups). Perhaps I'm just doing something dumb? But this confused me (from page 156 of the manual):

Code:

PORT_A_PULLUPS
.........
Availability: Only 14 and 16 bit devices (PCM and PCH). (Note: use
SETUP_COUNTERS on PCB parts).
..........


Eh? What does setup_counters have to do with the pullups? Here's my test code:

Code:

#include <12F683.h>
#use delay(clock=4000000)
#fuses NOWDT,RC, NOCPD, NOPROTECT, MCLR, NOPUT, BROWNOUT, IESO, FCMEN
#define downbutton PIN_A4
#define upbutton PIN_A5

void main()
{
    setup_adc_ports(0);
      setup_adc(ADC_OFF);
      setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
      setup_timer_1(T1_DISABLED);
      setup_comparator(NC_NC_NC_NC);
      setup_vref(FALSE);
   set_tris_a(0b110000); //all outputs except A4 and A5
   port_a_pullups(0b110000); //pullups on A4 and A5
        setup_timer_2(T2_DIV_BY_1, 124, 1);
      setup_ccp1(CCP_PWM);
      set_pwm1_duty(10);
      while (1)
      ;
}



Thanks in advance.

Avery

EDIT:

http://www.ccsinfo.com/forum/viewtopic.php?t=23063&highlight=12f683
explains some of the issue.

Just got the company CC, time to get the current ver of the 12F compiler.

Thanks

Avery


Last edited by amcfall on Thu Oct 20, 2005 11:57 am; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Oct 20, 2005 11:54 am     Reply with quote

Quote:
First off, let me make sure I have my pin definitions correct.

They're correct.

Quote:
I first tried INTRC_IO then INTRC, no luck. For some reason it
only seems to work when I use RC.

Make the changes shown in bold below.

#include <12F683.h>
#use delay(clock=4000000)
#fuses NOWDT,INTRC_IO, NOCPD, NOPROTECT, MCLR, NOPUT, BROWNOUT, IESO, FCMEN
#define downbutton PIN_A4
#define upbutton PIN_A5

void main()
{
setup_oscillator(OSC_8MHZ);


Quote:

(Note: use SETUP_COUNTERS on PCB parts).
What does setup_counters have to do with the pullups

It applies only to the PCB compiler. You're using PCM, so ignore it.
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