I'm trying to use the Weak Pull Ups (WPU register) to pull-up GP5 and GP3, and I cannot get it to work. Both GP5 and GP3 seem to be floating inputs, in spite of my best efforts. I'm not sure if I'm doing something stupid, or if PICC is getting in my way?
Code:
/*
Simple timer using 12F683
Desired behavior at Port Pins:
---------------------------------------------------------------------------
GP0 always driven as an output (YES)
GP1,GP2 is an output which is either hiZ or driven Low (YES)
GP3 is not used as MCLR, therefore is input, pulled high by WPU bit (NO)
GP4 is CLKOUT (YES)
GP5 is input, pulled high by WPU (NO)
*/
#include <12F683.h>
#use delay(clock=125000)
#use fast_io(A)
#byte WPU=0x95 //my attempt at enabling pull ups
#fuses NOWDT,INTRC, NOCPD, NOPROTECT, NOMCLR, PUT, BROWNOUT, IESO, FCMEN
void main()
{
unsigned long cnt; //16 bit counter
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_32);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
setup_oscillator( OSC_125KHZ | OSC_INTRC); //switch to slow internal clock
output_A(0); //set all port bits low.
WPU=0x28; //pull up GP5 and GP3
do
{ set_tris_A(0b00101110); //float GP1 & GP2
for(cnt=0;cnt<=20;++cnt) //cnt<=65535 is 23 hours
{ output_A(1); //tick bit high
delay_ms(1163); //delay 1.163 sec
output_A(0); //tick bit low
delay_ms(100); //delay 0.1 sec
}
set_tris_A(0b00101000); //Drive GP1 & GP2 LOW
for(cnt=0;cnt<=10;++cnt) //cnt<=2848 is one hour
{ output_A(1); //tick bit high
delay_ms(631); //delay 0.631 sec
output_A(0); //tick bit low
delay_ms(632); //delay 0.632 sec
}
}
while (1); //loop forever
}
Last edited: