bmagistro
- 8th March 2009, 18:26
Hello all,
Finally have a question that the search hasn't answered for me. I have a pic18f24k20 that reads 8 a/d lines and then based on the values of the a/d lines it controls 8 additional output pins that control other things in this case an optoisolator. My issues is this: portb.1 will not go high when in a check loop for say a/d channel. The code runs and says it goes high but the output does not. However if I type high portb.1 in the main program loop it will take it high accordingly. This is the only issue I am having at this time with the code. The block of code being referenced is shown below along with appropriate registers.
Thanks for the help in advance. Btw, great site.
OSCCON = %01010111 'configure oscillator settings
define OSC 4 'define oscillator as 4 Mhz
TRISA = %00101111
TRISB = %11111101
TRISC = %11000000
batcell1:
'PortB.2-AN8, PortB.1-RB1
adcon2 = %10110100
adcon0 = %00100001
Pauseus 50
adcon0.1 = 1
While ADCON0.1=1:Wend
adtmp.HighByte=ADRESH
adtmp.LowByte=ADRESL
rawad[0] = adtmp
adval[0] = rawad[0]
if adval[0] => turnon then
bypass[0] = 1
high PORTB.1
else
bypass[0] = 0
low PORTB.1
endif
return
Finally have a question that the search hasn't answered for me. I have a pic18f24k20 that reads 8 a/d lines and then based on the values of the a/d lines it controls 8 additional output pins that control other things in this case an optoisolator. My issues is this: portb.1 will not go high when in a check loop for say a/d channel. The code runs and says it goes high but the output does not. However if I type high portb.1 in the main program loop it will take it high accordingly. This is the only issue I am having at this time with the code. The block of code being referenced is shown below along with appropriate registers.
Thanks for the help in advance. Btw, great site.
OSCCON = %01010111 'configure oscillator settings
define OSC 4 'define oscillator as 4 Mhz
TRISA = %00101111
TRISB = %11111101
TRISC = %11000000
batcell1:
'PortB.2-AN8, PortB.1-RB1
adcon2 = %10110100
adcon0 = %00100001
Pauseus 50
adcon0.1 = 1
While ADCON0.1=1:Wend
adtmp.HighByte=ADRESH
adtmp.LowByte=ADRESL
rawad[0] = adtmp
adval[0] = rawad[0]
if adval[0] => turnon then
bypass[0] = 1
high PORTB.1
else
bypass[0] = 0
low PORTB.1
endif
return