Microcontroller Systems and Applications

ETE 344

Course Description:

        Microprocessor/microcontroller organization, operation, assembly-language programming and input/output applications. A/D conversions and real-time interrupts.

LAB 1        3

Objective:        3

Prelab:        3

Equipment, Software, and Components required:        3

Lab:        3

a. Flowchart the problem.        4

b. Convert the flowchart to a PIC18F assembly language program at        5

address 0x100. Do not use Loop and indirect addressing mode.        5

c. Write a PIC18F assembly language program for part b using Loop and        6

indirect addressing mode.        6

Procedure:        6

Conclusion:        6

LAB 2        7

Objectives:        7

Equipment, Software, and Components required:        7

Description        7

References:        7

Lab:        7

(a) Flowchart the problem.        8

(b) Convert the flowchart to PIC18F assembly language program.        9

Procedure:        10

Conclusion        10

LAB 3A        11

Objectives:        11

Equipment, Software, and Components required:        11

Description        11

References:        11

Laboratory        12

LAB 4        15

Objectives:        15

Problem:        15

Equipment, Software, and Components required:        15

Description        15

References:        15

Laboratory:        17

Conclusion:        18

LAB 5        19

Objective:        19

Prelab:        19

Equipment, Software, and Components required:        19

Procedure:        20

Conclusion:        21

LAB 6        21

Objectives:        21

Problem:        21

Equipment, Software, and Components required:        22

Procedure        22

References:        22

Laboratory:        23

Conclusion:        24

LAB 7        24

Objective:        24

Description:        24

Equipment, Software, and Components required:        24

Procedure:        24

Laboratory:        26

ADCON Registers:        27

Setting the ADCON0 ( A/D Control Register 0)        27

Setting the ADCON1 ( A/D Control Register 1)        27

Setting the ADCON2 ( A/D Control Register 2)        28


LAB 1

Objective:

The purpose of this lab is to assemble and debug a PIC 18F assembly language program using Microchip's MPLAB assembler.

Prelab:

Assemble and execute the tutorial program written in PIC18F assembly language using MPLAB.

Equipment, Software, and Components required:

Microchip’s MPLAB assembler /Debugger

Lab:

 It is desired to add two 24-bit data items in memory as shown in the figure below. Store the result pointed to by 0x50. The operation with sample data is given by

  F1 91 B5

PLUS    07 A2 04

---------------------------------

 F9 33 B9

SUM    3    2    1

F1

0x20 (address in ascending order)

91

0x21

B5

0x22

0x50

04

A2

0x51

07

0x52


a. Flowchart the problem.


b. Convert the flowchart to a PIC18F assembly language program at

address 0x100. Do not use Loop and indirect addressing mode.

INCLUDE <P18F4321.INC>

SUM1         EQU                 0x30        ; sum of byte 1

SUM2         EQU                 0x31        ; sum of byte 2

SUM3        EQU                 0x33        ; sum of byte 3

        ORG                 0x100

        MOVLW                 0xF1

        MOVWF                 0x20         ; stores F1 in 0x20 (byte 1)

        MOVLW                 0x91

        MOVWF                 0x21         ; stores 91 in 0x21        (byte 2)        

        MOVLW                 0xB5

        MOVWF                 0x22         ; stores B5 in 0x22 (byte 3)

        MOVLW                 0x04

        MOVWF                 0x50         ; stores 04 in 0x50 (byte 1)

        MOVLW                 0xA2

        MOVWF                 0x51         ; stores 51 in 0x51        (byte 2)        

        MOVLW                 0x07

        MOVWF                 0x52         ; stores 07 in 0x52 (byte 3)

        MOVF                 0x22,W         ; brings (byte 1)B5 back in to WREG so we can add to it

        ADDWF                 0x50,W        ; adds (byte 1)04 to B5 storing it in WREG

        MOVWF                 SUM1        ; storing the sum (04+B5) = B9 the first byte in SUM1

        MOVF                0x21,W        ;brings (byte 2) 91 in for adding 51

        ADDWFC                0x51,W        ;Adds (byte 2) A2 to 91 checking to see if SUM1 had a carry

        MOVWF                 SUM2        ;storing the sum (91+A2)=33 with a carry=1 the first byte in SUM2

        

        MOVF                0x20,W        ;brings (byte 3) F1 in for adding 04

        ADDWFC                0x52,W        ;Adds (byte 3) 07 to F1 checking to see if SUM2 had a carry

        MOVWF                 SUM3        ;storing the sum (F1+07)=F8+1(carry)= F9 the first byte in SUM3

        SLEEP

        END

 c. Write a PIC18F assembly language program for part b using Loop and

indirect addressing mode.

;begin         loop

                MOVLW                D'3'

COUNTER                MOVWF                0x29                 ; counter = 3

                LFSR                0,0x22                 ; ptr0 points to 0x50

                LFSR                1,0x50                 ; ptr0 points to 0x50

                LFSR                2,0x30                 ; ptr0 points to 0x50

                MOVLW                D'0'

LOOP                MOVFF                POSTDEC0,W

                ADDWFC                POSTINC1,W

                MOVWF                POSTINC2

                DECF                COUNTER,F

                BNZ                LOOP

                

;return from loop

Procedure:

Conclusion:

        On this laboratory we successfully assembled and debugged a program using Microchip’s MPLAB assembler that added two 24-bit data items in the memory.


LAB 2

Objectives:

Equipment, Software, and Components required:

Description

This lab utilizes a pointer, FSR1 to point to Xi’s. A subroutine will be written in PIC18F assembly language which will use a loop to compute the summation of 8 numbers. The main program will also be written in PIC18F assembly language which will use the hardware the stack

pointer (STKPTR) to call the subroutine.

References:

http://technology.niagarac.on.ca/staff/mboldin/18F_Instruction_Set/

Lab:

It is desired to write a subroutine in PIC18F assembly language to compute    

7

        Z =  ∑ Xi

i=0

Assume the Xi’s are unsigned 8-bit and stored in consecutive locations starting at 0x50.

0x50

0x30 FSR1 counter

0x00

0x50 (address in ascending order)

0x01

0x02

0x03

0x04

0x05

0x06

0x07

0x57

(a) Flowchart the problem.


(b) Convert the flowchart to PIC18F assembly language program.

INCLUDE <P18F4321.INC>

RESULT         EQU                         0x20        ; sum

                ORG                 0x100

        

                MOVLW                0x05

                MOVWF                STKPTR

                MOVLW                0x00

                MOVWF                0x50

                MOVLW                0x01

                MOVWF                0x51

                MOVLW                0x02

                MOVWF                0x52

                MOVLW                0x03

                MOVWF                0x53

                MOVLW                0x04

                MOVWF                0x54

                MOVLW                0x05

                MOVWF                0x55

                MOVLW                0x06

                MOVWF                0x56

                MOVLW                0x07

                MOVWF                0x57

                CALL                ADDER

;divide by 8

                BCF                 STATUS,C

                RRCF                 RESULT,F

                BCF                 STATUS,C

                RRCF                 RESULT,F

                BCF                 STATUS,C

                RRCF                 RESULT,F

                SLEEP

                ORG                0x200

ADDER                MOVLW                D'8'

COUNTER                MOVWF                0x30 ;                 counter = 8

                LFSR                0,0x50 ; ptr0 points to 0x50

                MOVLW                D'0'

LOOP                ADDWF                POSTINC0,W

                DECF                0x30,F

                BNZ                LOOP

                MOVWF                RESULT

                RETURN

                SLEEP

                END

Procedure:

i) Assemble and verify the PIC18F assembly language programs for the

main program and the subroutine of part (b) using the MPLAB.

ii) Demonstrate using the MPLAB how the hardware stack pointer

(STKPTR) changes with the execution of the PIC18F CALL and

RETURN instructions.

Conclusion

This lab’s objective was to add numbers 0-7 then dive the sum by 8 which would give out the average. To follow the structure of the program a flow chart was made. First thing to do is the assign our values 0-7 in an address in the memory then assign a counter starting at 8.  A loop was then used for the addition of all the numbers. With a counter in the loop, it will count down and stop until all the numbers have been used. Once the loop has finished it will go back to the main code and divide the sum by 8. Since the assembly language does not have a divide function we can still divide by rotating the bits using RRCF. Since a carry can change things when rotating the carry would have to be cleared before starting the rotating. Rotating it three times will be the equivalent of dividing it by 8. Using Watch, it is shown that the sum of 0-7 is 28 (1C in hex) and the result after dividing would be 3. The result would be 3 and not 3.5 since the remainder would not be used.


LAB 3A

Objectives:

Equipment, Software, and Components required:

Description

ASCII numbers are 8-bit numbers with the high 4 bits as 00112 or 310.

These numbers can be converted to packed BCD by masking off the high 4 bits.

Since the numbers to be added are 16-bit wide, one can convert the numbers into 8-bit packed BCD by masking off the high 4-bits of each ASCII number.

The high byte can be shifted 4 times to the left and logically ORed with the low byte.

The two converted 8-bit packed BCD numbers can then be added.

 

References:

http://technology.niagarac.on.ca/staff/mboldin/18F_Instruction_Set/


Laboratory

  1. Write a C language program to add two 16-bit numbers by converting each number from the ASCII number representation into a packed BCD byte.

# include <p18f4321.h>

void         main (){

        unsigned char

         LB1 = 0x32 //32H

        ,HB1 = 0x31 //31H

        ,HBLB1                

        ,LB2 = 0x34

        ,HB2 = 0x32

        ,HBLB2                

        ,result;

         LB1 = LB1 & 0x0f;                  //02H                 // Mask off upper four bits

        HB1 = HB1 & 0x0f;                  //01H                 // Mask off upper four bits

        HB1 = HB1 << 4;                  //10H                // Shift high byte 4 times to left

        HBLB1 = HB1 | LB1;                  //12                 // Packed BCD byte in addr3

         

        LB2 = LB2 & 0x0f;                 //4          

        HB2 = HB2 & 0x0f;                 //2          

        HB2 = HB2 << 4;                 

        HBLB2 = HB2 | LB2;                  //24                //HBLB2 24        

        

        result = HBLB1 + HBLB2;          //36

}


  1. Write a PIC18F assembly program to accomplish the above

                #include <p18f4321.INC>

                ORG                 0x100

HB1                EQU                0x21

LB1                EQU                0x22

HBLB1                EQU                0x23

HB2                EQU                0x61

LB2                EQU                0x62

HBLB2                EQU                0x63

AND0F                EQU                0x50

RESULT                EQU                0x24

                MOVLW                0x0F

                MOVWF                AND0F

                MOVLW                0x31

                MOVWF                HB1

                MOVLW                0x32

                MOVWF                LB1

                MOVLW                0x32

                MOVWF                HB2

                MOVLW                0x34

                MOVWF                LB2

                MOVF                HB1,W                        ;loads 31H

                ANDWF                AND0F,F                         ;HB1 = 31H & 0FH = 01H

                MOVFF                AND0F,HB1

                MOVLW                0x0F

                MOVWF                AND0F

                MOVF                LB1,W                        ;loads 32H

                ANDWF                AND0F,F                         ;LB1 = 32H & 0FH = 02H

                MOVFF                AND0F,LB1

                MOVLW                0x0F

                MOVWF                AND0F

        

                BCF                STATUS,C                ;begin logic shift        

                RRCF                HB1,F        

                RRCF                HB1,F        

                RRCF                HB1,F        

                RRCF                HB1,F

                RRCF                HB1,F

                                                        ;combining HB and LB

                MOVLW                0x10                        ;loads 10H

                IORWF                LB1,F                        ;HBLB1 = 10H | 02H = 12H

                MOVFF                LB1,HBLB1

;hblb2                                                

                MOVF                HB2,W                        ;loads 34H

                ANDWF                AND0F,F                         ;HB2 = 34H & 0FH = 02H

                MOVFF                AND0F,HB2

                MOVLW                0x0F

                MOVWF                AND0F

                MOVF                LB2,W                        ;loads 34H

                ANDWF                AND0F,F                         ;LB2 = 34H & 0FH = 04H

                MOVFF                AND0F,LB2

                MOVLW                0x0F

                MOVWF                AND0F

        

                BCF                STATUS,C                ;begin logic shift        

                RRCF                HB2,F        

                RRCF                HB2,F        

                RRCF                HB2,F        

                RRCF                HB2,F

                RRCF                HB2,F

                                                        ;combining HB and LB

                MOVLW                0x20                        ;loads 10H

                IORWF                LB2,F                ;HBLB1 = 10H | 02H = 12H

                MOVFF                LB2,HBLB2

                

                MOVF                HBLB1,W

                ADDWF                HBLB2,W

                MOVWF                RESULT

 

                SLEEP

                END


LAB 4        

Objectives:

Problem:

The PIC18F4321 microcontroller is required to drive the LEDs connected to bit 0 of ports C and D based on the input conditions set by switches connected to bit 1 of ports C and D. The I/O conditions are as follows:

Write a PIC18F assembly and C Language program that accomplishes this

Equipment, Software, and Components required:

Description

Implement a PIC18F based stand-alone by interfacing DIP switches and LEDs to using the PICKit2 and the MPLAB software.

References:

http://technology.niagarac.on.ca/staff/mboldin/18F_Instruction_Set/


Laboratory:

//leds

PORT C Bit 0 PIN 15

PORT D Bit 0 PIN 19

//switches

Port C bit 1 PIN 16

Port D bit 1 PIN 20

#INCLUDE<p18f4321.INC>

                CONFIG        OSC = INTI02

                CONFIG        WDT = OFF

                CONFIG        LVP = OFF        

                CONFIG        BOR = OFF

                

                ORG 0x100

SETBITS        BCF                TRISC, 0         ; LED 1 PORT C bit 0 output

                BCF                TRISD, 0        ; LED 2 PORT D bit 0 output

                BSF                TRISC, 1        ; SW1 PORT C bit 1 input

                BSF                TRISD, 1        ; SW2 PORT D bit 1 input

OFF                BCF                PORTC, 0        ;C0 LED

                BCF                PORTD, 0        ;D0 LED

ON                BSF                PORTC, 0        ;C0 LED

                BSF                PORTD, 0        ;D0 LED

LOOP                BTFSS                PORTC ,1        ;If (C1 == 1)

                BRA                LOOP2                ;False: C1 = 0

                BTFSS                PORTD, 1        ;True:if(C1 == 1 && D1 ==1)

                BSF                PORTC, 0        ;False: C1 > D1 , LED C1 ON

                BRA                ON                ;True: C1 = D1= 1

LOOP2                BTFSS                PORTD ,1        ;If (D1 == 1)

                BRA                ON                ;False: D1 = 0

                BTFSS                PORTC, 1        ;True: if (D1 == 1 && C1 == 1)

                BSF                PORTD, 0        ;False: (D1>C1), LED D1 ON

                BRA                ON                ;True: D1 = C1 = 1

        

                SLEEP

                END

#include<p18f4321.h>

#pragma config        OSC = INTIO2

#pragma config        WDT = OFF

#pragma config        LVP = OFF        

#pragma config        BOR = OFF

#define C0 PORTCbits.RC0

#define C1 PORTCbits.RC1

#define D0 PORTDbits.RD0

#define D1 PORTDbits.RD1

Void main(){

TRISC = 0x02;

TRISD = 0x02;

if (C1 == 1 && D1 == 0){

        C0 =1;

        D0=0;

}

else if ( D1 ==1 && C1 ==0){

        C0 = 0;

        D0 =1;

}

else{

        C0 =1;

        D0 =1;

        }

}

Conclusion:

This lab required us to use DIP switches for the two inputs at C and D and LEDs as outputs for C and D in order to follow three conditions. These conditions were that if input C is HIGH and the input at port D is LOW. The LED at C will be on and D will be off. The next condition was that it if the C input is LOW and D is HIGH, C will be off and D will be on. The last condition would be if both inputs are either HIGH or LOW then both outputs will be on. The microcontroller was programmed using assembly and C languages. In assembly several branches and bit set instructions were used so that each input can be read  and branch towards its appropriate output. In C, if else loops and digital logic were used to make the conditions true.


LAB 5

Objective:

Design and implement hardware and software (C-program) for

adding two 3-bit numbers entered via DIP Switches and display the result

(0-9) on a Seven-Segment Display.

Prelab:

The PIC18F4321 microcontroller is required to add two 3-bit numbers

entered via DIP switches connected at port D of the PIC18F4321, and

output the sum (not to exceed 9) to a common-Anode seven-segment

display connected at port C . Assume that the first 3-bit number and

the second 3-bit number are entered via six DIP switches connected at

bits 0-2 and bits 3-5 of Port D. Write a C language program to accomplish this.

Equipment, Software, and Components required:

-Microchip’s MPLAB C18 Compiler /Debugger

-Parts List

 PICKit3 and PIC18F4321 chip from Microchip

 DIP Switches, Seven-segment Display, and a push button for reset

 Breadboard

 Resistors

 Power Supply

Procedure:

-Compile the C language program using the MPLAB.

-Download the compiled program into the PIC18F4321 on the breadboard

from your Personal Computer or Laptop using the PICKit3 and MPLAB

following the steps provided in Appendix H of the book.

-Use the default clock of the PIC18F4321 and connect the appropriate

RESET circuit to the PIC18F4321 pin.

-Connect the DIP switches to port D and the seven-segment display to port

C, and demonstrate the lab as a PIC18F4321-based stand-alone system.

#include<p18f4321.h>

#pragma config        OSC = INTIO2

#pragma config        WDT = OFF

#pragma config        LVP = OFF        

#pragma config        BOR = OFF

Void main (){

unsigned char result, num1, num2;

num1 = PORTD;

num1 = num1 & 0x07; // num 1 0000XXX

num2 = PORTD;

num2 = num2 & 0x38; // num 2 = 0XXX000

num2 = num2 >> 3;   // num 2 = 0000XXX

//0000XXX num1

//0000XXX num2

result =   num1 + num2;

PORTC = result;

}

Conclusion:

On this laboratory we successfully designed and implemented a hardware software C-program that added two 3 bit numbers. The numbers were entered via Dip switches that were connected to port D on the PIc18F4321, and the result was displayed on a seven segment display that was connected to port C. The program used was written in C language using the MPLAB software. We first began the program by declaring the header in which we set our default parameters of our PIC. We then begin our code. We read our first 3 bit number from port D bits 0-2, which was then masked to only keep the first 3 bits. Next we read our second number from port D bits 3-5 and masked it to keep the  bits 3-5. The bits were then shifted 3 times to the right. Thus, it allowed us to add the two numbers together. The resulted sum  was finally displayed on the Port C bits 0-2  that was connected to a 7-segment display.

LAB 6

Objectives:

Problem:

The PIC18F4321 microcontroller is required to test a NAND gate. The above figure shows the I/O hardware needed to test the NAND gate. The microcontroller is to be programmed to generate the various logic conditions for the NAND inputs and outputs, and turn the LED ON connected at bit 3 of port D if the e faulty. Otherwise, turn the LED ON connected at bit 4 of port D. Write a PIC18F assembly and C Language program that accomplishes this

Equipment, Software, and Components required:

Procedure

References:

http://technology.niagarac.on.ca/staff/mboldin/18F_Instruction_Set/


Laboratory:

        #include<p18f4321.h>

        #pragma config        OSC = INTIO2

        #pragma config        WDT = OFF

        #pragma config        LVP = OFF        

        #pragma config        BOR = OFF

        #define D0 PORTDbits.RD0

        #define D1 PORTDbits.RD1

        #define D2 PORTDbits.RD2

        #define D3 PORTDbits.RD3

        #define D4 PORTDbits.RD4

        void main(){

                TRISD = 0x04;

                D0 = 0; D1 = 0;                                //NAND INPUTS  0  0

                if (D2 == 1){                                // IF NAND OUTPUT IS 1

                        D3 = 0; D4 = 1;                        // TEST LED on

                }

                else{ D3 = 1; D4 = 0;                        // IF NAND OUTPUT IS 0

                while (D3 == 1){D3 = 1; D4 = 0;}                // LEAVE FAULTY LED ON

                }

                D0 = 1; D1 = 0;

                if (D2 == 1){

                        D3 = 0; D4 = 1;

                }

                else{ D3 = 1; D4 = 0;

                while (D3 == 1){D3 = 1; D4 = 0;}

                }

                D0 = 0; D1 = 1;

                if (D2 == 1){

                        D3 = 0; D4 = 1;

                }

                else{ D3 = 1; D4 = 0;

                while (D3 == 1){D3 = 1; D4 = 0;}

                }

                D0 = 1; D1 = 1;                                //NAND INPUTS  1  1

                if (D2 == 0){                                // IF NAND OUTPUT IS 0

                        D3 = 0; D4 = 1;                        // TEST LED on

                }

                else{ D3 = 1; D4 = 0;;                        // IF NAND OUTPUT IS 1

                while (D3 == 1){D3 = 1; D4 = 0;}                // LEAVE FAULTY LED ON

                }

        }

Conclusion:

This lab asked to use the PIC18F4321 Microcontroller to test if a NAND gate is functioning properly. Since port D is declared as the output, five ports were used to read the NAND gate and for LED’s. Two LED’s were used so that they can function as a test for the NAND gate. One LED will be on indicating the NAND gate is plugged in and that it follows through the logic of its truth table. The second LED is used to indicate that the NAND gate is not connected correctly or that it does not follow the logic of a NAND gate. The microcontroller was programmed to test the NAND gate using C. All 4 possible 2-bit inputs was made to have an if-else and a while statement. So for state zero the two inputs for the NAND would be 0 and 0.

LAB 7

Objective:

Design and build a PIC based digital voltmeter using analog to digital converter

Description:

In the above figure, the PIC is used to implement a voltmeter to measure voltage in the range of 0-5 V and display the result in two decimal digits: one integer and one fractional.Write a PIC assembly or C program to accomplish this.

Equipment, Software, and Components required:

-Microchip’s MPLAB C18 Compiler /Debugger

-Parts List

 PICKit12 and PIC18F4321 chip from Microchip

Seven-segment Display, and a push button for reset

Procedure:

-Compile the C language program using the MPLAB.

-Download the compiled program into the PIC18F4321 on the breadboard

from your Personal Computer or Laptop using the PICKit3 and MPLAB

following the steps provided in Appendix H of the book.

-Use the default clock of the PIC18F4321 and connect the appropriate

RESET circuit to the PIC18F4321 pin.

-Connect the DIP switches to port D and the seven-segment display to port

C, and demonstrate the lab as a PIC18F4321-based stand-alone system.


Laboratory:

#include<P18F4321.h>

#pragma config        OSC = INTIO2

#pragma config        WDT = OFF

#pragma config        LVP = OFF        

#pragma config        BOR = OFF

unsigned int FINAL,ADCONRESULT;        //Initialize variables

unsigned char D1, D0;

void CONVERT(){

        D1 = FINAL/10;                

D0 = FINAL % 10;                //D0 is remainder of FINAL divided by 10

}

void main (){

TRISD=0x00;                                // Port D is Output

TRISC=0x00;                                 // Port C is Output

ADCON0= 0x01;                                // Configure the ADC registers

ADCON1 = 0x0D;

ADCON2 = 0x29;

D0=0;                                        //Data to display '0' on integer 7-seg display

D1=0;

while(1){                                //Data to display '0' on fractional 7-seg display

ADCON0bits.GO = 1;                //Start the ADC

while(ADCON0bits.GO == 1);        //Delay until conversion complete

PORTC = D1;                        //Output d1 TO integer 7-segment display

PORTD = D0;                        //Output D0 TO fractional 7-segment

        ADCONRESULT = ADRESH;                //Move the ADC result into ADCONRESULT

        FINAL =(ADCONRESULT*10)/51;        //Conversion factor

        CONVERT();

        }

}

ADCON Registers:

Setting the ADCON0 ( A/D Control Register 0)

Bit 7-6 Unimplemented: Read as ‘0’

Bit 5-2 CHS3:CHS0: Analog Channel Select bits

Bit 1 GO/DONE: A/D Conversion Status bit

Bit 0 ADON: A/D On bit

        ADCON0 = 00 0000 0 1 = 0x01

Setting the ADCON1 ( A/D Control Register 1)

Bit 7-6 Unimplemented: Read as ‘0’

Bit 5 VCFG1: Voltage Reference Configuration bit (VREF - source

        1 = VREF- (AN2)

        0 = VSS

Bit 4 VCFG0: Voltage Reference Configure bit ( VREF+ source)\

1 = VREF- (AN3)

        0 = VDD

Bit 3-0 PCFG3:PCFG0: A/D Port Configuration Control bits

                -        -        Vss = 0                VDD = 0                DDDDDDDDDDDAA = 13

ADCON1 =        0        0              0                        0                           1101 = 0x0D


Setting the ADCON2 ( A/D Control Register 2)

Bit 7 ADFM: A/D Result Format Select bit

1 = Right justified; 10 bits in [ADRESH] = 000000XX and [ADRESL] = XXXXXXXX

0 = Left justified; 8 bit result in [ADRESH] =0x00 and [ADRESL] = XXXXXXXX

Bit 6 Unimplemented: Read as ‘0’

Bit 5-3 ACQT2:ACQT0: A/D Acquisition Time Select bits

111 = 20 TAD

011 = 6 TAD

110 = 16 TAD

010 = 4 TAD

101 = 12 TAD

001 = 2 TAD

100 = 8 TAD

000 = 0 TAD(1)

Bit 2-0 ADCS2:ADCS0: A/D Conversion

111 = FRC

011 = FRC

110 = FOSC/64

010 FOSC/32

101 = FOSC/16

001 = FOSC/8

100 = FOSC/4

000 = FOSC/2

Left Justified = 0            - = 0                 12 TAD = 101                FOSC/8  =001

ADCON2 =            0                 0                         101                       001 = 0x29