elec_mech
- 17th August 2006, 16:06
Hi everyone! I've been flipping through the 390 page PIC 18F2525 manual for over an hour and I can't figure out how to make RA6 an output. I believe it is set as a second oscillator (OSC2) by default. Here is a simple test code I've been using to flash an LED:
' Setup
Trisa = %00000000 ' Set all port a pins as outputs
Trisb = %00000000 ' Set all port b pins as outputs
Porta = %00000000 ' Set all pins on port a as low
Portb = %00000000 ' Set all pins on port b as low
Adcon1 = $0F ' Disable the A/D converter
Start:
porta.6 = 1
portb.1 = 1
pause 500
porta.6 = 0
portb.1 = 0
pause 500
goto Start
The LED on portb.1 works fine, but not on porta.6.
The manual mentions setting the config1h register, but here I have 2 problems: 1) the default setting is said to be config1h = 00--0111 where the 0111 is an external RC Oscillator with port function on RA6 (which would imply, at least to me, that RA6 is already set to be a standard I/O and 2) the manual is very unclear on how to change the configuration register. I've searched many a post and all I find are sippets of assembly code (which I am utterly unfamiliar and want to avoid at all costs). Also, I don't know if changing the config1h register will actually enable me to use the RA6 pin as an output.
I am using the PICDEM 2 Plus demo board which has a external clock setup. I want to use the setup outlined on page 24 of the 18F2525 datasheet - ECIO on the bottom, right. Anyone have any advice?
' Setup
Trisa = %00000000 ' Set all port a pins as outputs
Trisb = %00000000 ' Set all port b pins as outputs
Porta = %00000000 ' Set all pins on port a as low
Portb = %00000000 ' Set all pins on port b as low
Adcon1 = $0F ' Disable the A/D converter
Start:
porta.6 = 1
portb.1 = 1
pause 500
porta.6 = 0
portb.1 = 0
pause 500
goto Start
The LED on portb.1 works fine, but not on porta.6.
The manual mentions setting the config1h register, but here I have 2 problems: 1) the default setting is said to be config1h = 00--0111 where the 0111 is an external RC Oscillator with port function on RA6 (which would imply, at least to me, that RA6 is already set to be a standard I/O and 2) the manual is very unclear on how to change the configuration register. I've searched many a post and all I find are sippets of assembly code (which I am utterly unfamiliar and want to avoid at all costs). Also, I don't know if changing the config1h register will actually enable me to use the RA6 pin as an output.
I am using the PICDEM 2 Plus demo board which has a external clock setup. I want to use the setup outlined on page 24 of the 18F2525 datasheet - ECIO on the bottom, right. Anyone have any advice?