PDA

View Full Version : 1936 ra.7 i/o ???



MOUNTAIN747
- 30th March 2020, 19:06
So I’m stumped over this one. Using a PIC16F1936 on a lighting project. Trying to run some simple code to blink A.7, A.6, C.0, C.1, C.2, …….. All lights are blinking except PortA.7.


; MPASM
asm
__config _CONFIG1,_FOSC_INTOSC & _CLKOUTEN_OFF & _MCLRE_ON & _BOREN_OFF & _WDTE_OFF & _FCMEN_OFF & _CP_OFF & _CPD_OFF & _IESO_OFF
__config _CONFIG2, _WRT_OFF & _PLLEN_OFF & _STVREN_ON & _BORV_LO & _LVP_OFF
endasm

define osc 8
;--[ Set Hardware ]---------
OSCCON=%01110000
ANSELA=$0
ANSELB=$0
ADCON0=$0
PortA=0
PortB=0
PortC=0
TrisA=0
TrisB=0
TrisC=0

Start:
PortA.7=1
pause 500
PortA.6=1
pause 500
PortC.0=1
pause 500
PortC.1=1
stop
END

RA.6 and RA.7 are also oscillator pins and must be set to I/O outputs in CONFIG1 with CLKOUTEN=1 (_CLKOUTEN_OFF) and FOSC= INTOSC (CLKOUTEN_OFF). According to the data sheet this should give digital I/O on both RA.6 and RA.7. RA.6 is responding as expected. RA.7 is NOT giving me a digital output. I have tried on multiple 1936’s on my design board and LAB-X2. No 5V output on RA.7. What have I overlooked?
Thanks,
Wayne

Charlie
- 31st March 2020, 12:27
Usually when a single pin doesn't do what you expect it's a configuration error. A quick look at the datasheet suggests the only other possible use for the pin is OSC1/CLKIN. You should be able to test the idea by changing OSCCON from %01110000 to %01110010. If that's the case, your configuration words are not getting loaded for some reason.

Dave
- 31st March 2020, 20:19
Instead of using the PORTA.7 directive, why not use the LATA.7 directive? You maybe seeing the Read/Modify/Write problem. Try it....

MOUNTAIN747
- 31st March 2020, 22:38
Thanks guys, I'll give it a try.