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

12f675 GP2 has no internal pull-up resistor?

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



Joined: 07 Jul 2010
Posts: 92

View user's profile Send private message

12f675 GP2 has no internal pull-up resistor?
PostPosted: Thu Jul 08, 2010 7:35 am     Reply with quote

Hi,

I've enabled internal pull-ups but input(GP2) returns 0...

I initialize the pic using these codes:
Code:
#include <12F675.h>
#device adc=10

#FUSES WDT,INTRC_IO,CPD,PROTECT,NOMCLR,PUT,BROWNOUT

#use fast_io(A)

#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 delay(clock=4M,RESTART_WDT)

#byte gpio = getenv("SFR:GPIO")
.
.
.
   gpio = 0;
   set_tris_a(0b011111);
   port_a_pullups(TRUE);
   setup_adc_ports(sAN0|sAN1|VSS_VDD);
   setup_adc(ADC_CLOCK_INTERNAL);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_comparator(NC_NC);
   setup_vref(FALSE);
   setup_wdt(WDT_288MS);
   disable_interrupts(GLOBAL);

   gpio = 0;

And GP2 is not connected anywhere, just blank.

I could not see any note in the datasheet that GP2 has no internal pull-up resistor?

Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jul 08, 2010 12:17 pm     Reply with quote

Quote:
I've enabled internal pull-ups but input(GP2) returns 0...

1. Post a complete test program where you actually call this line of code.
The program should be compilable if I copy-and-paste it into MPLAB.

2. Explain how you know that the pin returns 0. The program should
have a short section that does something based on the returned value.
This could be setting an LED on or off, for example.

3. Tell if you're running this test in hardware or in Proteus.

4. Try to make a test program without all that extra code at the start
of main() that is unnecessary (such as disabling peripherals that are
already disabled upon power-on reset of the PIC).

5. Post your compiler version.
FFT



Joined: 07 Jul 2010
Posts: 92

View user's profile Send private message

PostPosted: Fri Jul 09, 2010 10:37 am     Reply with quote

I'm testing on a real pcb and the GP2 is blank. My compiler version is 4.107.

in this code below led does not work. If I write GP4 instead of GP2 in if statement, led works (GP4 is already blank). I use GP0-1 as ADC but I removed the adc_read code.
Code:
#include <12F675.h>
#device adc=10

#FUSES WDT                      //Watch Dog Timer
#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT
#FUSES CPD                      //Data EEPROM Code Protected
#FUSES PROTECT                  //Code protected from reads
#FUSES NOMCLR                   //Master Clear pin used for I/O
#FUSES PUT                      //Power Up Timer
#FUSES BROWNOUT                 //Reset when brownout detected

#use fast_io(A)

#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 delay(clock=4M,RESTART_WDT)

#byte gpio = getenv("SFR:GPIO")

#bit  Led  = gpio.5

#rom 0x3ff={0x345C} // Calibration Word

void main(void)
{   
   gpio = 0;
   set_tris_a(0b011111);
   port_a_pullups(TRUE); //*****

   setup_adc_ports(sAN0|sAN1|VSS_VDD);
   setup_adc(ADC_CLOCK_INTERNAL);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_comparator(NC_NC);
   setup_vref(FALSE);
   setup_wdt(WDT_288MS);
   disable_interrupts(GLOBAL);

   gpio = 0;

   if(input(GP2) == 1) // returns 0
      Led=1;

//   if(input(GP4) == 1) // returns 1
//      Led=1;

   for(;;)
   delay_us(1);
}


Thanks in advance.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jul 09, 2010 11:55 am     Reply with quote

The 12F675 has individual enables for each pin. You have to use a
bitmask as the parameter for the port_a_pullups() function. You can't
use True/False on this PIC. Do it similar to the way you do the TRIS.
FFT



Joined: 07 Jul 2010
Posts: 92

View user's profile Send private message

PostPosted: Sat Jul 10, 2010 9:30 am     Reply with quote

It works!!! Smile Thank you very much!
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