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

Port A wierdness on 16F884

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








Port A wierdness on 16F884
PostPosted: Tue Jan 22, 2008 8:12 am     Reply with quote

I have a problem when using port A on a PIC16F884. Reading this port always returns a zero. I use a relay on the board to indicate the state. The input to port A is a 6 position DIP switch and a 3 position toggle switch. The toggle is on A0,A1 and the DIP switch is on the rest. They are all pulled up to +5V with 10k resistors. Any help would be greatly appreciated.

I have the PUMP_MODE, SPLX_DPLX, etc #define'd to individual port A pins in the following code.

Code:

   set_tris_a(0b11111111);
   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_oscillator(OSC_8MHZ);
   setup_timer_0(RTCC_INTERNAL);
   //enable_interrupts(GLOBAL);
   //enable_interrupts(int_timer0);
   //print_display(123456);
   while(TRUE) {
// DIP switch routines *********************************************************
      if(!input(SPLX_DPLX)) duplex=1; else duplex=0; // Simplex/duplex operation
      if(!input(PUMP_MODE)) { // Pump up/pump down mode selection
         off_float=input(OFF_FLT);
         lead_float=input(LEAD_FLT);
         lag_float=input(LAG_FLT);
         output_high(PUMP1);
      } else {
         off_float=!input(OFF_FLT);
         lead_float=!input(LEAD_FLT);
         lag_float=!input(LAG_FLT);
         output_low(PUMP1);
      }
      if(!input(START_PUMP)) pump_order=1; else pump_order=0; // Pump ordering
      if(!input(ALTERNATION)) alternate=1; else alternate=0; // Pump alternation
// *****************************************************************************
Guest








PostPosted: Tue Jan 22, 2008 8:26 am     Reply with quote

It looks like answered my own question. I had to clear the ANSEL register (0x188) since it appears that the ADC setup functions of CCS neglect to do so.
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