How to set external clock source in PBP
I am trying to use an external resonator with my circuit and I was wondering what i set
DEFINE ADC_CLOCK to to use an external 20mhz resonator.
I already set OSC to 20, but that doesn't seem to work. Also, how do I set an 8 bit data word acquired from an analog in, to output bit by bit, say through the entire PORTB. I was going to wire it up to 8 LEDs to make sure it was working and I can't find any documentation on how to set an entire port to output an 8 bit digital word. My code is as follows:
' PicBasic Pro program to perform
' 8-bit A/D conversion
'
' Connect analog input to (RA0)
' Connect LEDs to 8 pins of PORTB
include "modedefs.bas"
' Define ADCIN parameters
Define ADC_BITS 8 ' Set number of bits in result
DEFINE OSC 20 ' Sets clock speed to 20Mhz
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
adval var byte ' Create adval to store result
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %00000010 ' Set PORTA analog
TRISB = %00000000 ' Set PORTB to all output
Pause 500 ' Wait .5 second
SHIFTOUT PORTB,PORTA.7,0,[adval] ' Output 8 bit word to PORTB
Pause 500 ' Wait .5 second
' Do A/D conversion after each pixel shift
loop: ADCIN 0, adval ' Read channel 0 to adval
Goto loop ' Do it forever
End