ABL electronic PIC12 Personal Computer User Manual


 
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
14 0
MikroElektronika:
Development
tools
-
Books
-
Compilers
page
Library Example
/* This code snippet reads analog value from channel 2 and displays
it on PORTD (lower 8 bits) and PORTB (2 most significant bits). */
unsigned temp_res;
void main() {
ADCON1 = 0x80;
// Configure analog inputs and Vref
TRISA = 0xFF;
// PORTA is input
TRISB = 0x3F;
// Pins RB7, RB6 are outputs
TRISD = 0;
// PORTD is output
do {
temp_res = Adc_Read(2);
// Get results of AD conversion
PORTD = temp_res;
// Send lower 8 bits to PORTD
PORTB = temp_res >> 2;
// Send 2 most significant bits to RB7, RB6
} while(1);
}
4MHz
+5V
+5V
PIC16F877A
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
Hardware Connection