




























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























to setup the ADC module.
ADC block diagram as shown below. AN0 – AN analog input pin Reference Voltage Scheme
The A/D module has four registers. These registers are: ◦ A/D Result High Register (ADRESH) ◦ A/D Result Low Register (ADRESL) ◦ A/D Control Register 0 (ADCON0) ◦ A/D Control Register 1 (ADCON1)
The result obtained after converting an analog value into digital is a10-bit number that is to be stored in the ADRESH and ADRESL registers. There are two ways of handling it: ◦ left and right justification which simplifies its use to a great extent. The format of conversion result depends on the ADFM bit of the ADCON1 register. ◦ In the event that the A/D converter is not used, these registers may be used as general-purpose registers.
Analog Channel Select bits select a pin or an analog channel for A/D conversion, i.e. voltage measurement:
ADON - A/D On bit enables A/D converter.
Bit 0 – Bit 3 (A/D Port Configuration Control bits) How to determine bit 0 to bit 3 logic?
Bit 6(A/D Conversion Clock Select bit (ADCON1 bits in shaded area and in bold ) ADCS2 bit work closely with ADCS1:ADCS0 bits (ADCON0) in order to select clock frequency used for internal synchronization of A/D converter
The A/D conversion time per bit is defined as TAD. The A/D conversion requires a minimum 12TAD per 10-bit conversion. The source of the A/D conversion clock is software selected. The seven possible options for TAD are: ◦ 2 TOSC ◦ 4 TOSC ◦ 8 TOSC ◦ 16 TOSC ◦ 32 TOSC ◦ 64 TOSC ◦ Internal A/D module RC oscillator (2-6 us) For correct A/D conversions, the A/D conversion clock (TAD) must be selected to ensure a minimum TAD time of 1.6 us.
In addition to A/D converter, there is another module, which so called analog electronics. Two high quality comparators, along with additional electronics, are integrated into the microcontroller and connected to its pins. The comparator module contains two analog comparators. The inputs to the comparators are multiplexed with I/O port pins RA 0 through RA 3 , while the outputs are multiplexed to pins RA 4 and RA 5
Comparator output bit Comparator output inversion bit Comparator input switch bit Comparator mode bits
Refer to PIC16F87XA datasheet, there are 8 possible ways to configure analog comparator module which is <CM2:CM0>: ◦ Comparators Reset <000> ◦ One Independent Comparator with Output<001> ◦ Two Independent Comparators<010> ◦ Two Independent Comparators with Outputs<011> ◦ Two Common Reference Comparators<100> ◦ Two Common Reference Comparators with Outputs<101> ◦ Four Inputs Multiplexed to Two Comparators<110> ◦ Comparators Off (POR Default Value)<111>