(One intermediate revision by the same user not shown)
Line 8: Line 8:
 
{| class="table table-striped table-hover table-condensed table-bordered"
 
{| class="table table-striped table-hover table-condensed table-bordered"
 
|-class="info"
 
|-class="info"
!Adc Channel || Pic16f877a Pin  
+
!Adc Channel || Pic16f877a Pin || Pin Function
 
|-
 
|-
|0|| PA.0
+
|0|| PA.0 || AN0
|-      
+
|-      
|1|| PA.1
+
|1|| PA.1 || AN1
|-      
+
|-      
|2|| PA.2
+
|2|| PA.2 || AN2/VREF-
|-      
+
|-      
|3|| PA.3
+
|3|| PA.3 || AN3/VREF+
|-          
+
|-            
|4|| PA.5
+
|4|| PA.5 || AN4
|-      
+
|-      
|2|| PE.0
+
|2|| PE.0 || AN5
|-      
+
|-      
|3|| PE.1
+
|3|| PE.1 || AN6
|-          
+
|-        
|4|| PE.2
+
|4|| PE.2 || AN7
 
|}<br><br>
 
|}<br><br>
  
 
=Code=
 
=Code=
 +
Below is the sample code to read the ADC value of channel0 and sent it on UART at 9600 baud rate.<br>
 +
As the POT is connected to ADC0, the values can be varied using this POT.
 
<html>
 
<html>
 
<script src="https://gist.github.com/sharanago/83a7537783383c8130576a79a493c87a.js"></script>
 
<script src="https://gist.github.com/sharanago/83a7537783383c8130576a79a493c87a.js"></script>

Latest revision as of 18:58, 2 May 2016

In this tutorial we will see how to read the ADC values on PIC16f877A starter board.
Starter board comes with on board POT connected to ADC0, same POT value will be read and transmitted on UART at 9600 baudrate.

PIC16F877A ADC pins

PIC16F877A has inbuilt 8channel 10-bit ADC. Below tables shows the ADC pin mapping.

Adc Channel Pic16f877a Pin Pin Function
0 PA.0 AN0
1 PA.1 AN1
2 PA.2 AN2/VREF-
3 PA.3 AN3/VREF+
4 PA.5 AN4
2 PE.0 AN5
3 PE.1 AN6
4 PE.2 AN7


Code

Below is the sample code to read the ADC value of channel0 and sent it on UART at 9600 baud rate.
As the POT is connected to ADC0, the values can be varied using this POT.

Pic16f877aADC01.PNG

Demo

Pic16f877aADC00.gif