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

PIC16HV785 and port_a_pullups problem

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








PIC16HV785 and port_a_pullups problem
PostPosted: Mon Apr 21, 2008 6:52 am     Reply with quote

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;
      }   
     
      if(ms_pulse) { // One millisecond pulse
         ms_pulse=0; // Reset flag
         milliseconds++; // Increment timer
         if(milliseconds>=time_delay) {
            if(!input(INT_TMR)) output_low(RELAY);
            if(input(ON_TMR)) output_high(RELAY);
            while(TRUE);
         }
      }
   }
}
Guest








Update
PostPosted: Mon Apr 21, 2008 11:25 am     Reply with quote

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