program ADC_Test
dim temp_res as word
main:
ADCON1 = $80
' configure analog inputs and Vref
TRISA = $ff
' designate PORTA as input
TRISB = $3F
' designate RB7,RB6 pins as outputs
TRISD = $0
' designate PORTD as output
while true
temp_res = ADC_read(2)
' now you can use temp_res ...
PORTD = temp_res
' send lower 8 bits to PORTD
PORTB = word(temp_res >> 2)
' send two most significant bits to PORTB
wend
end.
Figure (ADC HW connection)
mikroBASIC
- Basic Compiler for Microchip PIC microcontrollers
112
mikroBASIC
MikroElektronika: Development tools - Books - Compilers
Komentáře k této Příručce