Micro.p Lab 6 (Adc of 16f877a Uc) microcontroller 16f877a...
Description
Microprocessors & Computer Interfacing
Lab 5:
ADC of 16f877A uC
ADC of 16f877A uC.
Objectives: 1. Learn to use the ADC module on the 16f877A uC.
Introduction: An analog-to-digital converter (A/D) is another important peripheral component of a microcontroller. The A/D converts an analog input voltage into a digital number so it can be processed by a microcontroller or any other digital system. The PIC 16F877A microcontroller contain a 8-channel 10-bit ADC. If the chosen voltage refrence is +5V, the voltage step (resolution) value is:
Therefore, for example, if the input voltage is 1.0V the converter will generate a digital output of 1.0/0.00489 = 205 decimal. Similarly, if the input voltage is 3.0V, the converter will generate 3.0/0.00489 = 613. The ADC used by the PIC 16F877A microcontroller has eight channels, named AN0AN7, which are shared by the PORTA and PORTE pins. The ADC module has four registers. These registers are: • ADC Result High Register (ADRESH) • ADC Result Low Register (ADRESL) • ADC Control Register 0 (ADCON0) • ADC Control Register 1 (ADCON1) In this experiment only the ADC Control Register 1 (ADCON1) is used to control the channels of the converter.
1
Microprocessors & Computer Interfacing
ADC of 16f877A uC
ADCON1 Register: The ADCON1 register configures the functions of the port pins. The port pins can be configured as analog inputs (RA3 can also be the voltage reference) or as digital I/O.
Bits 0 to 3 i.e. PCFG0-PCFG3 are the ADC port configuration control bits. Figure 6.1 shows all possible settings for these bits.
Figure 6.1
MikroC PRO ADC Library: MikroC PRO provides an easy to use library functions that simplifies configuring the ADC module and reading the analogue channels. Below is a detailed description of the ADC_Read function.
2
Microprocessors & Computer Interfacing
ADC of 16f877A uC
Prototype : unsigned ADC_Read(unsigned short channel). Returns : 10 or 12-bit unsigned value read from the specified channel. Example : unsigned tmp;
...
tmp = ADC_Read(2);
// Read analog value from channel 2
Example 1: Connect the circuit shown in Figure 6.2 in Proteus and compile the program of example 1 given below.
Thank you for interesting in our services. We are a non-profit group that run this website to share documents. We need your help to maintenance this website.