Hi All,
I have now swapped over to PIC16F1823 for this project and I am now having difficulty using pins on PORTA as inputs with Weak Pull-ups enabled.
I have stripped down my code as follows:
The program flashes LED1 and LED2 as expected but I get strange readings when I probe PORTA.1, .2, .4 or .5 with my oscilloscope.Code:#CONFIG __config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _BOREN_OFF __config _CONFIG2, _PLLEN_OFF & _LVP_OFF & _WRT_HALF #ENDCONFIG OSCCON = %01101000 ; Fosc = 4MHz ; Clock determined by Fosc<1:0> Config Word DEFINE OSC 4 ; Define oscillator as 4MHz ANSELA = 0 ; Set PORTA as digital I/O ANSELC = 0 ; Set PORTC as digital I/O ADCON0.0 = 0 ; Disable ADC DACCON0.7 = 0 ; Disable DAC CM1CON0.7 = 0 ; Disable comparator 1 CM2CON0.7 = 0 ; Disable comparator 2 CPSCON0.7 = 0 ; Disable CPS module T1CON.7 = 0 ; Timer1 OFF TRISC = 0 ; All PORTC as outputs TRISA = 1 ; All PORTA as inputa OPTION_REG.7 = 0 ; Enable Weak Pull-ups WPUA = %00111111 ; Pull-ups enabled on PORTA LED1 var PORTC.5 LED2 var PORTC.1 Start: ; Flash LED1 and LED2 at 1Hz high LED1 High LED2 Pause 500 low LED1 low LED2 pause 500 Goto Start
With PORTA set as digital inputs and weak pull-ups enables on PORTA I would expect those pins to read +5v but they are in fact reading 0v
I need to connect switches to PORTA.2, .4 and .5 to make selections for my program to function but can't switch these pins to ground if they are already permanently there!
Can anyone shed any light on what might be happening or what I might be doing wrong?
Cheers
Barry
VK2XBP




Bookmarks