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

16LF1828 RA4 Weak Pullup

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



Joined: 05 Mar 2012
Posts: 99
Location: Central Illinois

View user's profile Send private message

16LF1828 RA4 Weak Pullup
PostPosted: Wed Aug 01, 2012 10:24 am     Reply with quote

PIC16LF1828
PCM V 4.132

My intention is to use RA4 as a digital input.
I am attempting to turn on it's weak pull ups.
I believe I have the analog ports correctly defined so that RA4 is digital.
I have called NOCLKOUT to disable the function on this pin.
I believe I have my TRIS registers set as needed.

What I definitely do not have is a high signal on RA4. It seems as if the weak pull up is not active and software is reading it as a LOW.

I know this is something silly that I have overlooked but I've gone cross eyed from reading through the datasheet. Any help would be appreciated.

ps...the wrap-around makes it difficult to read the INITIALIZE_PINS; macro. Sorry.

Code:

#include <16LF1828.h>
#device adc=10
#use delay (internal = 8000000)

#FUSES INTRC_IO,NOWDT,NOPUT,MCLR,NOBROWNOUT,NOLVP,NOCPD,NOWRT,NODEBUG,NOPROTECT,NOCLKOUT,NOIESO,NOFCMEN,NOWRT,NOSTVREN

#define INITIALIZE_PINS OUTPUT_A(0b00000011); OUTPUT_B(0x00); OUTPUT_C(0x00); SET_TRIS_A(0b00110100); SET_TRIS_B(0x20); SET_TRIS_C(0b11001011); output_high(MOSFET_POWER_PIN); PORT_A_PULLUPS(ON_BUTTON_PIN | CYCLE_BUTTON_PIN | MOM_BUTTON_PIN);
#define SET_CLOCK_8MHZ SETUP_OSCILLATOR(OSC_8MHZ);

#define MOSFET_POWER_PIN  PIN_B6
#define ON_BUTTON_PIN     PIN_A2
#define CYCLE_BUTTON_PIN  PIN_A4
#define MOM_BUTTON_PIN    PIN_A5

#use fast_io(A)
#use fast_io(B)
#use fast_io(C)

void main(void)
{
  //set pins as input or output.  set all outputs low. turn on power mosfet
  INITIALIZE_PINS;


  //set clock frequency
  SET_CLOCK_8MHZ;

  #ifdef COMPILE_FOR_CCS
  //Initalize Timer 1, load it with the starting value, and enable interrupt flags
  SETUP_TIMER_1(T1_FOSC | T1_DIV_BY_1);

//rolling over timer1 at a specific interval to increment various counters
  SET_TIMER1(PWM_ON_timer_count);
  ENABLE_INTERRUPTS(GLOBAL);
  ENABLE_INTERRUPTS(PERIPH);
  ENABLE_INTERRUPTS(INT_TIMER1);

//Specify which ports are used as Analog Inputs and initialize the A/D Converter
  SETUP_VREF(VREF_ON | VREF_ADC_2v048 | TEMPERATURE_INDICATOR_ENABLED | TEMPERATURE_RANGE_LOW);
  SETUP_ADC(ADC_CLOCK_DIV_2);
  SETUP_ADC_PORTS(sAN4 | sAN5 | sAN7 | sAN8 | sAN9 | sAN11 | VSS_FVR);
  SET_ADC_CHANNEL(4);

  while(1)
  {

  }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Aug 01, 2012 1:51 pm     Reply with quote

Quote:
PORT_A_PULLUPS(ON_BUTTON_PIN | CYCLE_BUTTON_PIN | MOM_BUTTON_PIN);

Download the manual. Look up the correct parameters for the
port_a_pullups() function:
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf
stinky



Joined: 05 Mar 2012
Posts: 99
Location: Central Illinois

View user's profile Send private message

PostPosted: Wed Aug 01, 2012 2:35 pm     Reply with quote

sheesh....

thank you so much.

PORT_A_PULLUPS(0b00110100); got the desired effect.
Grossly misread the header file on that one.
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