stinky
Joined: 05 Mar 2012 Posts: 99 Location: Central Illinois
|
16LF1828 RA4 Weak Pullup |
Posted: Wed Aug 01, 2012 10:24 am |
|
|
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)
{
}
}
|
|
|