I have switches connected to RA0, RA1, RA2, RA4, and RA5. I would like to use the internal pullups on these pins but cannot seem to get it to function properly. Here is the code:
Code:
void main(void) {
int32 milliseconds, time_delay;
setup_oscillator(OSC_8MHZ); // Setup internal oscillator to 8MHz
set_tris_a(0b00111111); // Setup TRIS register for port A
setup_adc_ports(sAN6); // Dial pot is on analog channel 6
setup_adc(ADC_CLOCK_INTERNAL); // Use normal clock
set_adc_channel(6); // Set ADC MUX to channel 6
setup_timer_0(RTCC_INTERNAL | RTCC_DIV_16); // Set up the millisecond timer
setup_timer_1(T1_INTERNAL | T1_DIV_BY_8);
port_a_pullups(0b00110100); // Enable pullup resistors on port A
enable_interrupts(INT_RTCC);
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);
while(TRUE) {
if(!input(INT_TMR)) output_high(RELAY); // Turn on relay
if(input(ON_TMR)) output_low(RELAY); // Turn off relay
switch(0x10) {
case SEC_1: time_delay=SEC1_MS;
break;
case SEC_10: time_delay=SEC10_MS;
break;
case MIN_1: time_delay=MIN1_MS;
break;
case MIN_10: time_delay=MIN10_MS;
break;
}
It appears after examining the code deeper that the ANSEL registers need to be manually written to to allow the operation of the port_a_pullups() for this part.
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