MikroElektronika PIC Microcontrollers PIC16 Manuel d'utilisateur Page 117

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 172
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 116
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
4MHz
+5V
+5V
PIC16F877
RA0/AN0
RA2/AN2/Vref-
RA3/AN3/Vref+
RA4/TOCKI
RA5/AN4
RE0/RD/AN5
RE1/WR/AN6
RE2/CS/AN7
Vdd
Vss
OSC1
OSC2
RCO/T1OSO
RC1/T1OSI
RC3
RD0/PSP0
RD1/PSP1
MCLR/Vpp/THV
RC2/CCP1
RA1/AN1
RB7/PGD
RB6/PGC
RB5
RB4
RB3/PGM
RB2
RB1
RB0/INT
Vdd
Vss
RD6/PSP6
RD7/PSP7
RD5/PSP5
RD4/PSP4
RC7/RX/DT
RC6/TX/CK
RC5
RC4
RD3/PSP3
RD2/PSP2
+5V
LD7
LD6
LD5
LD4
LD3
LD2
LD1
LD0
330R
330R
330R
330R
330R
330R
330R
330R
LB7
LB6
330R
330R
10K
Reset
making it simple...
page
Vue de la page 116
1 2 ... 112 113 114 115 116 117 118 119 120 121 122 ... 171 172

Commentaires sur ces manuels

Pas de commentaire