Lab Microprocessors
Lab Microprocessors
Lab Microprocessors
Aim
Interfacing memory chip, ROM in Proteus.
Requirements:
Theory
ROM:
Read-only memory is a memory device in which permanent binary information is stored. The number of
words in a ROM is determined from the k address input lines needed to specify the 2k words.
Task:
Write some content in ROM memory by a binary format file, apply the counter outputs to the address
lines of ROM and read the contents via Memory chip.
Lab 2: Interfacing Of RAM in Proteus
Aim
Interfacing memory chip, RAM in Proteus.
Requirements:
Theory
RAM:
Memory unit: Stores binary information in groups of bits called words. Memory word: group of 1’s
and 0’s and may represent a number, character(s), instruction, or other binary-coded information. Most
computer memories use words that are multiples of 8 bits (byte ). 32-bit word ‡ 4 bytes. Each word in
memory is assigned an address 0 up to 2k – 1 (k = # of address lines).
To transfer a new word to be stored into memory:
2. Apply the data bits that must be stored in memory to the data input lines.
Task:
Design a schematic that loads data from ROM to RAM starting from FFFFH,0000H,0001H to FFFEH
Give a ram address you should see the data of corresponding address will be shown in the output of
RAM
1)
2)
3)
Aim
Design and Implementation of 4 bit Arithmetic Logic Unit.
Requirements:
Theory
An Arithmetic Logic Unit (ALU) is a circuit that does arithmetic, such as addition, subtraction,
set‐less‐than, bit‐wise AND, bit‐wise OR, etc. The ALU you will design is a combinational circuit that
operates on 4‐bit numbers. It has two inputs A and B, and an output Y. It has four operations that can be
selected: add, subtract, set‐less‐than, and bit‐wise AND. To select the operation, the ALU has a 2‐bit
select input Sel which selects as follows
Block Diagram:
Lab 4: Address Decoding
Aim
Implementing address decoding using NAND gates.
Requirements:
Theory
With the information of desired address locations, It is the job of a decoder circuitry to locate the memory
chip to where desired data is to be stored. We look at the use of NAND gate IC as decoders:
The Address Information is taken from the ROM ICS, we will be needing a cascade of ROM ICs to make
a 20 bit address bus for the RAM ICs.
TASK:
of RAM1
Similarly ,
Of RAM2
Lab 6: Assembly language Instructions
(Branching, Time delay loops )
Lab Engineer:
1)
2)
3)
Aim
Introduction to branching and time delay loops in Assembly Language.
Theory
Chapter 3 of PIC Microcontroller and embedded systems by MAZIDI
Equipment
PC with MPLABX installed
DECFSZ file Reg , d ;decrement file Reg and skip next instruction if 0
In this instruction, the file Reg is decremented, and if its content is zero, it skips the next
instruction. By placing the "GOTO target" instruction right below it we can create a loop. The
target address of the "GOTO target" instruction is the beginning of the loop
Example 1
Write program to (a) clear WREG, and (b) add 3 to WREG ten times and place the result
in SFR of PORTB. Use the DECFSZ instruction to perform looping
AGAIN
BACK
In the last two instructions, the file Reg is decremented; if it is not zero, it branches (jumps) back
to the target address referred to by the label. Prior to the start of the loop, the file Reg is loaded
with the counter value for the number of repetitions. Notice that the BNZ instruction refers to the
Z flag of the status register affected by the previous instruction, DECF.
In the last two instructions, the file Reg is decremented; if it is not zero, it branches (jumps) back
to the target address referred to by the label. Prior to the start of the loop, the file Reg is loaded
with the counter value for the number of repetitions. Notice that the BNZ instruction refers to the
Z flag of the status register affected by the previous instruction
Example 2
Write a program to (a) clear WREG and then (b) add 3 to WREG ten times.Use the zero flag and
BNZ
#include P18f4520.inc
ORG 0H
CLRF TRISE
MOVLW d'10' ; WREG = 10 (decimal) for counter
MOVWF COUNT ; load the counter
MOVLW 0 ; WREG = 0
AGAIN
END
Because 700 is larger than 255 (the maximum capacity of any register), we use two registers to
hold the count. The following code shows how to use file Reg locations 25H and
26H as a register for counters.
#include P18f4520.inc
ORG 0H
R1 EQU Ox25
R2 EQU Ox26
COUNT_1 EQU d'l0'
COUNT_2 EQU d'70‘
CLRF TRISD
MOVLW Ox55 ;WREG = 55h
MOVWF PORTD ; PORTE = 55h
MOVLW COUNT_1 ;WREG = 10, outer loop count value
MOVWF R1 ;load 10 into lac 25H (outer loop count)
LOP 1 ;WREG = 70, inner loop count value
END
In this program; file Reg location Ox26 is used to keep the inner loop count. In the instruction
"BNZ LOP_2", whenever location 26H becomes 0 it falls through and "DECF Rl, F" is executed.
This instruction forces the CPU to load the inner count with 70 if it is not zero, and the inner
loop starts again. This process will continue until location 25 becomes zero and the outer loop is
finished
Stack
The stack is read/write memory (RAM) used by the CPU to store some very critical information
temporarily. This information usually is an address, but it could be data as well. The CPU needs
this storage area because there are only a limited number of registers. The stack in the PIC18 is
21-bit because the programcounter is 21-bit. This means that it is used for the CALL instruction
to make sure that the PIC knows where to come back to after execution of the called
subroutine.
In the PIC, the CPU uses the stack to save the address of the instruction just below the CALL
instruction. This is how the CPU knows where to resume when it returns from the called
subroutine. Consider following example
Example
Toggle all the bits of the SFR register of Port B by sending to it the values 55H and AAH
continuously. Put a time delay in between each issuing of data to Port B.
Task 2
Write program (using conditional branches) for nested loop (level 3) for toggling pin RD1 10000
times
Task 3
Create a delay of 1 sec assuming an oscillator frequency of 4MHz. Toggle pins of port D (in an
infinite loop) after every 1 sec.
Lab 6: Arithmetic Instructions
Lab Engineer:
Group Members
1)
2)
3)
Aim
Understanding following topics
Theory
Chapter 5 of PIC Microcontroller and embedded systems by MAZIDI.
Equipment
PC with MPLABX installed
Tasks Marks
1) Multiple byte addition 3
2) Multiple byte subtraction (unsigned numbers) 3
3) Multiple byte subtraction (signed numbers) 4
Explanation
ADDLW
The ADDLW instruction has the following format: ADDLW K ; ADD literal value K to WREG The
ADD instruction tells the CPU to add the literal value K to register WREG and put the result back
in the WREG register. Notice that in ADDLW, first comes the letter L (literal) and then the letter
W (WREG), which means "add a literal value to WREG," the destination. To add two numbers
such as 25H and 34H, one can do the following:
MOVLW 25H ; load 25H into WREG
ADDLW 34H ; add value 34 to W (W = W + 34H)
Executing the above lines results in WREG = 59H (25H + 34H = 59H)
ADDWF
Instruction "ADDWF fileReg, d" allows the addition ofWREG andindividual bytes residing in RAM
locations of the file register. Notice that WREGmust be involved because memory-to-memory
arithmetic operations are neverallowed in PIC Assembly language. To calculate the sum of any
number of operands, the carry flag should be checked after the addition of each operand.
ADDWFC
When adding two 16-bit data operands, we need to be concerned with the propagation of a
carry from the lower byte to the higher byte. This is called multibyteaddition to distinguish it
from the addition of individual bytes. The instruction ADDWFC (ADDW and fileReg with carry) is
used on such occasions.
Example
Write a program to add two 16-bit numbers. The numbers are 3CE7H and 3B8DH. Assume that
file Reg location 6 = (8D) and location 7 = (3B). Place the sum in file Reg locations 6 and 7;
location 6 should have the lower byte.
MOVLW 0xE7
ADDWF 0x6,F
MOVLW 0x3C
ADDWFC 0x7,F
Example
Write a program to subtract two 16-bit numbers. The numbers are 2762H- 1296H. Assume
fileReg location 6 = (62) and location 7 = (27). Place the difference in file Reglocations 6 and 7;
loc 6 should have the lower byte.
MOVLW 0x96
SUBWF 0x6,F
MOVLW 0x12
SUBWFB 0x7,F
TASK 1
Save Two unsigned nos of size n bytes on location starting from address 10H and 20H
respectively (n=7) add them and save result on location starting from address 30H.
TASK 2
Save Two signed nos of size n bytes on location starting from address 10H and 20H
respectively (n=7) add them and save result on location starting from address 30HDo
this two time, in one iteration result should be valid (no overflow) and in second
iteration result should be invalid(overflow occurs). Use overflow flag to check validity of
result.
Lab 7: Register Indirect addressing Mode
Instructor:
Lab Engineer:
Group Members
1)
2)
3)
Aim
Understanding Register indirect Addressing mode
Theory
Chapter 5 and 6 of PIC Microcontroller and embedded systems by MAZIDI.
Equipment
PC with MPLABX installed
Tasks Marks
4) Taking two’s compliment of n byte no 5
5) subtracting n byte no 5
Explanation
Register Indirect Addressing Mode
In the register indirect addressing mode, a register is used as a pointer to the data RAM
location. In the PICI8, three registers are used for this purpose: FSRO, FSRI, and FSR2. FSR
stands for file select register and must not be confused with SFR (special function register).
The FSR is a 12-bit register allowing access to the entire 4096 bytes of data RAM space in
the PIC18. We use LFSR (load FSR) to load the RAM address. In other words, when FSRx are
used as pointers, they must be loaded first with the RAM addresses as shown below
Because FSRO, FSRl, and FSR2 are 12-bit registers they cannot fit into the SFR address space
unless they are split into pieces of an 8-bit size. That is exactly what PIC I 8 has done. The
FSR registers have the low-byte and high-byte parts called FSRxL and FSRxH, as shown in the
SFR table of Table 6-1. In Table 6-1 we see FSROL and FSROH, representing the low and high
parts of the 12-bit FSRO register. Note that the FSRxH is only 4-bit and the upper 4 bits are
not used. Another register associated with the register indirect addressing mode is the INDF
(indirect register). Each of the FSRO, FSRl, and FSR2 registers has an INDF register associated
with it, and these are called INDFO, INDFI, and INDF2. When we move data into INDFx we
are moving data into a RAM location pointed to by the FSR. In the same way, when we read
data from the INDF register, we are reading data from a RAM location pointed to by the
FSR. This is shown below.
Example
Write a program to copy a block of 5 bytes of data from RAM locations starting at 30Hto RAM
locations starting at 60H.
TASK 1
Save an n(n=7) byte no is save on RAM starting 10H(MSB), find two’s complement of no
and place it on RAM staring from 20H(MSB)
TASK 2
Save two n(n=7) byte no on RAM starting 10H(MSB) and 20H(MSB) respectively ,
subtract operand 1 from operand 2 first take two’s complement of minuend using code
of task 1 and then use addition command
Lab 8: Pic Programming in C
1)
2)
3)
Lab Engineer:
Group Members
Aim
Understanding writing codes in C for PIC 18F microcontroller
Theory
1) Chapter 7 of PIC Microcontroller and embedded systems by MAZIDI.
2) Data sheet of PIC microcontroller
Equipment
PC with MPLABX and XC8 compiler installed.
Tasks Marks
6) Binary to decimal conversion 4
7) BCD to ASCII conversion 4
Explanation
Reason behind C programming of pic
The following are some of the major reasons for writing programs in C instead of Assembly.
I. It is easier and less time consuming to write in C than in Assembly.
2. C is easier to modify and update.
3. You can use code available in function libraries.
4. C code is portable to other microcontrollers with little or no modification.
Example
Following C code toggles all pins of PORTC and PORTD continuously with an approximate
delay of 250ms
#include <P18F458.h>
voidMSDelay(unsigned int);
void main(vd)
{
TRISC = 0;
TRISD = 0;
while(1)
{
PORTC = 0x55;
PORTD = 0x55;
MSDelay(250);
PORTC = 0xAA;
PORTD = 0xAA;
MSDelay(250);
}
}
voidMSDelay(unsigned intitime)
{
unsignedinti; unsigned char j;
for(i=0;i<itime;i++)
for(j=0;j<165;j++);
}
Task1
Write a Cl8 program to convert packed BCD to ASCII and display the bytes on PORTB and
PORTC
Task2
Write a C18 program to convert FD hex to decimal and display the digits on PORTB, PORTC,
and PORTD
Lab 9: Introduction to hardware
Lab Engineer:
Group Members
1)
2)
3)
Aim
At the end of lab student should be able to program microcontroller IC.
Theory
Chapter 8 of PIC Microcontroller and embedded systems by MAZIDI.
Equipment
PC with MPLABX and proteus installed, PICKit3, PIC 18F452, +5v Battery or power
supply, 20 MHz Crystal, 10kΩ Resistor, 1uF Capacitor, 5mm LED, Breadboard, Breadboard Wire,
Battery Holder
TaskMarks
8) Toggle LED connected to PORTD.1 after every 1sec 10
Explanation
Make connection of microcoxntroller with accessories as shown in figure 1 and figure 2
Task
Write a program to toggle pin RD1 after every 1 sec. Connect LED to RD1. (first run simulation in
proteus)
Lab 10: Generating square wave using timer
Instructor:
Lab Engineer:
Group Members
1)
2)
3)
Aim
At the end of lab student should be able to understand working of timers
Theory
Chapter 9 of PIC Microcontroller and embedded systems by MAZIDI.
Equipment
PC with MPLABX and proteusinstalled,PICKit3, PIC 18F452, +5v Battery or power
supply, 20 MHz Crystal, 10kΩ Resistor, 1uF Capacitor, 5mm LED, Breadboard, Breadboard
WireSIPs, Battery Holder, Oscilloscope
TaskMarks
9) Generating square wave of variable frequency using timers 10
Explanation
Timer0 16-bit timer programming
The following are the characteristics and operations of 16-bit mode:
1. It is a 16-bit timer; therefore, it allows values of 0000 to FFFFH to be loaded into the
registers TMROH and TMROL.
2. After TMROH and TMROL are loaded with a 16-bit initial value, the timer must be
started. This is done by “BSF TOCON, TMROON" for Timer 0.
3. After the timer is started, it starts to count up. It counts up until it reaches its limit of
FFFFH. When it rolls over from FFFFH to 0000, it sets HIGH a flag bit called TMROIF
(timer interrupt flag, which is part of the INTCON register). This timer flag can be
monitored. When this timer flag is raised, one option would be to stop the timer.
4. After the timer reaches its limit and rolls over, in order to repeat the process, the
registers TMROH and TMROL must be reloaded with the original value, and the TMROIF
flag must be reset to 0 for the next round.
To generate a time delay using the Timer mode 16, the following steps are taken:
1. Load the value into the TOCON register indicating which mode (8-bit or 16-bit) is to be
used and the selected prescaler option.
2. Load register TMROH followed by register TMROL with initial count values.
3. Start the timer with the instruction "BSF T OCON, TMROON".
4. Keep monitoring the timer flag (TMROIF) to see if it is raised. Get out of the loop
when TMROIF becomes high.
5. Stop the timer with the instruction "BCF T OCON, TMROON".
6. Clear the TMROIF flag for the next round.
7. Go back to Step 2 to load TMROH and TMROL again. To clarify the above steps, see
Example 9-3. To calculate the exact time delay and the square wave frequency
generated on pin PB5, we need to know the XTAL frequency
TMROL, because the value for TMROH is kept in a temporary register and written to
TMROH when TMROL is loaded. This will prevent any error in counting ifthe TMROON
flag is set HIGH.
Example
Assuming that XTAL = I0 MHz, write a program to generate a square wave with a period of 10
ms on pin PORTB.3.
For a square wave with T = I0 ms we must have a time delay of 5 ms. Because XTAL= I0 MHz,
the counter counts up every 0.4 11s. This means that we need 5 msI 0.4 uS =12,500 clocks.
65,536- 12,500 = 53,036 = CF2CH. Therefore, we have TMROH = CF and TMROL = 2C.
Code
BCF TRISB,3
MOVLW 0x08
MOVWF T0CON
HERE MOVLW 0xCF
MOVWF TMR0H
MOVLW 0x2C
MOVWF TMR0L
BCF INTCON,TMR0IF
CALL DELAY
BTG PORTB,3
BRA HERE
DELAY BSF T0CON,TMR0ON
AGAIN BTFSS INTCON,TMR0IF
BRA AGAIN
BCF T0CON,TMR0ON
RETURN
Task
Receive 8 bit value from port B and move to TMROH and TMROL and generate square wave.
Calculate all possible frequency (255 frequencies) you can generate using this method by
writing Matlab code.
10) Run code in proteus simulation
11) Run code on hardware and observe output on oscilloscope.
Optional
1) Suppose beside value of timer you are also receiving 3 bit value for pre scalar. Now
again calculate all possible frequency you can generate using pre scaler and timer
values
2) Write code for generating square wave of varying duty cycle
Lab 11: LCD Interfacing
Instructor:
Lab Engineer:
Group Members
1)
2)
3)
Aim
At the end of lab student should be able to understand working of LCD and using it for
displaying information.
Theory
Chapter 12of PIC Microcontroller and embedded systems by MAZIDI.
Equipment
PC with MPLABX and proteus, Matlab and Vspd/Vspe installed PICKit3, PIC18 generic
board or pic dem2 plus demonstration board, Serial cable, LCD
TaskMarks
1) Display name and registration on LCD 10
Explanation
LCD pin descriptions
LCD (Liquid Crystal Display) display module to PIC microcontroller? LCD is a passive component
that is it does not make any light but just modifies the light passing through it for alphanumeric
displays. LCD is exclusively manufactured to be used withmicrocontrollers, which means that
it cannot be triggered by usual IC circuits Details of particular LCD are given in its data sheet.
Text book may also be consulted here only brief description is given
Control pins
(R/S , R/W , E pins)
The control pin RS determines if the data transfer between the LCD module and an external
microcontroller are actual character data or command/status. When the microcontroller needs
to send commands to LCD or to read the LCD status, it must be pulled low. Similarly, this must
be pulled high if character data is to be sent to and from the LCD module. The direction of data
transfer is controlled by the R/W pin. If it ispulled Low, the commands or character data is
written to the LCD module. And, when it is pulled high, the character data or status information
from the LCD registers is read. Here, we will use one way data transfer, i.e., from
microcontroller to LCD module, so the R/W pin will be grounded permanently. The enable pin
(E) initiates the actual data transfer. When writing to the LCD display, the data is transferred
only on the high to low transition of the E pin.
Circuit Diagrams
Connect LCD to microcontroller according to following connections. Basic connections of
microcontroller are not shown
Task
Make circuit according to the above diagram and write a program to display your name (in first line) and
registration no(in second line).(First run simulation in proteus)
Lab 12: Serial communication
Lab Engineer:
Group Members
1)
2)
3)
Aim
At the end of lab student should be able to understand serial communication basic
concepts and implement serial communication protocol between PIC18 and MATLAB
Theory
Chapter 10 of PIC Microcontroller and embedded systems by MAZIDI.
Equipment
PC with MPLABX , Proteus, Matlab and Vspd/Vspe installed ,PICKit3, pic 18 generic
board with serial port or pic dem2 plus demonstration ,Serial cable
Task BreakdownMarks
12) Receiving serial data using Simulink block 5
13) Receiving serial data using Matlab code 5
Explanation
Programming the PIC18 to transfer data serially
In programming the PIC 18 to transfer character bytes serially, the following steps must be
taken:
I. The TXSTA register is loaded with the value 20H, indicating asynchronous mode with 8-bit
data frame, low baud rate, and transmit enabled.
2. Make TX pin ofPORTC (RC6) an output for data to come out of the PIC.
3. The SPBRG is loaded with value to set the desired baud rate for serial data transfer.
4. SPEN bit in the RCSTA register is set HIGH to enable the serial port of the PIC18.
5. The character byte to be transmitted serially is written into the TXREG register.
6. Monitor the TXIF bit ofthe PIRI register to make sure UART is ready for next byte.
7. To transfer the next character, go to Step 5.
Example
Assume a switch is connected to pin RD7. Write a program to monitor its status and send two
messages to the serial port continuously as follows: SW = 0 send "NO" ,SW = I send "YES"
Assume XTAL = 10 MHz, and set the baud rate to 9,600.
Code
BSF TRISD,7
MOVLW 0x20
MOVWF TXSTA
MOVLW D'15'
MOVWF SPBRG
BCF TRISC, TX
BSF RCSTA, SPEN
OVER BTFSS PORTD,7
BRA NEXT
MOVLW high(MESS1)
MOVWF TBLPTRH
MOVLW low(MESS1)
MOVWF TBLPTRL
FN TBLRD*+
MOVF TABLAT,W
BZ EXIT
CALL SENDCOM
BRA FN
NEXT MOVLW high(MESS2)
MOVWF TBLPTRH
MOVLW low(MESS2)
MOVWF TBLPTRL
LN TBLRD*+
MOVF TABLAT,W
BZ EXIT
CALL SENDCOM
BRA LN
EXIT MOVLW 0x20
CALL SENDCOM
GOTO OVER
SENDCOM
S1 BTFSS PIR1, TXIF
BRA S1
MOVWF TXREG
RETURN
MESS1 DB "NO",0
MESS2 DB "YES",0
Task1
Write a program to send linearly increasing 8 bit noin infinite loop from PIC 18 and receive this data in
Matlab.( sawtooth waveform should be displayed in MATLAB)
Task2
Program microcontroller with code given in example and receive this data in Simulink.
Instructor:
Lab Engineer:
Group Members
1)
2)
3)
Aim
At the end of lab student should be able to understand how to process multiple tasks
using priority interrupt feature of microcontroller
Theory
Chapter 11 of PIC Microcontroller and embedded systems by MAZIDI.
Equipment
PC with MPLABX,proteus, Matlab and Vspd/Vspe installed,PICKit3, PIC18 generic board
with serial port or pic dem2 plus demonstration board,Serial cable
TaskMarks
14) Two Square waves generation with Variable duty cycle and time period
Received serially 10
Explanation
Steps in executing an interrupt
Upon activation of an interrupt, the microcontroller goes through the following steps:
I. It finishes the instruction it is executing and saves the address of the next instruction
(program counter) on the stack.
2. It jumps to a fixed location in memory called the interrupt vector table. The interrupt vector
table directs the microcontroller to the address of the interrupt service routine (ISR).
3. The microcontroller gets the address of the ISR from the interrupt vector table and jumps to
it. It starts to execute the interrupt service subroutine until it reaches the last instruction of the
subroutine, which is RETFIE (return from interrupt exit).
4. Upon executing the RETFIE instruction, the microcontroller returns to the place where it was
interrupted. First, it gets the program counter (PC) address from the stack by popping the top
bytes of the stack into the PC. Then it starts to execute from that address.
Example
This program uses Timer 0 to generate a square wave on pin PORTB.5, while at the same time
data is being transferred from PORTC to PORTO.
ORG 0000H
GOTO MAIN
ORG 0008H
BTFSS INTCON,TMR0IF
RETFIE
GOTO T0_ISR
ORG 00100H
MAIN BCF TRISB,5
CLRF TRISD
SETF TRISC
MOVLW 0x08
MOVWF T0CON
MOVLW 0xFF
MOVWF TMR0H
MOVLW 0xF2
MOVWF TMR0L
BCF INTCON,TMR0IF
BSF T0CON,TMR0ON
BSF INTCON,TMR0IE
BSF INTCON,GIE
OVER MOVFF PORTC,PORTD
BRA OVER
T0_ISR
ORG 200H
MOVLW 0xFF
MOVWF TMR0H
MOVLW 0xF2
MOVWF TMR0L
BTG PORTB,5
BCF INTCON,TMR0IF
EXIT RETFIE
END
Task 1
You have to generate two square waves S1 and S2 simultaneously using timer 0 and timer 1. Off
time and ON time of square waves are given by user at port D. According to the following truth
table
PIN C0 PIN C.1 Data Type
0 0 S1 ON time
0 1 S1 Off time
1 0 S2 ON time
1 1 S2 Off time
Calculate duty cycle and time period from given on time and off time on paper.
Optional
Make following addition to above code
Use serial transmit interrupt and send data to Matlab and plot it in real time.
Lab 14: Data Acquisition using ADC and
Serial
Instructor:
Lab Engineer:
Group Members
1)
2)
3)
Aim
At the end of lab student should be able to understand how to use ADC and serial port
to plot analog signal in MATLAB
Theory
Chapter 11 and 13 of PIC Microcontroller and embedded systems by MAZIDI.
Equipment
PC with MPLABX, proteus, Matlab and Vspd/Vspe installed,PICKit3,PIC 18 generic board
with serial port or PIC dem2 plus demonstration board Serial cable
Task Marks
2) Digitizing analog sine signal(from function generator) using ADC and plot
in MATLAB 10
Explanation
Steps in programming the A/D converter using polling
To program the AID converter of the PIC18, the following steps must be taken:
1. Turn on the ADC module of the PICI8 because it is disabled upon power-on reset to save
power. We can use the "BSF ADCONO, ADON" instruction.
2. Make the pin for the selected ADC channel an input pin. We use "BSF TRISA, x." or "BSF
TRISE, x" where x is the channel number.
3. Select voltage reference and A/C input channels. We use registers ADCONO and ADCON1.
4. Select the conversion speed. We use registers ADCONO and ADCONI.
5. Wait for the required acquisition time.
6. Activate the start conversion bit of GO/DONE.
7. Wait for the conversion to be completed by polling the end-of-conversion (GO/DONE) bit.
8. After the GO/DONE bit has gone LOW, read the ADRESL and ADRESH registers to get the
digital data output.
9. Go back to step 5.
TASK
1) Apply sine wave of 1HZ 2vpp with 2v offset to AN0 PIN of microcontroller
2) Digitize it using ADC save only 8 bits not 10 bits
3) Send 1 byte data serially to MATLAB
4) In MATLB use previous code of serial reception to plot serial data in real time
5) To ensure that each sample digitized by ADC is sent serially use a register R3 of RAM and
set it if ADC reads sample and gives a byte and clear it if it is sent serially next time
don’t digitize a sample using ADC until R3 is zero i.e. ADC will wait for serial
transmitter if he send current byte then it will digitize next sample
6) First run simulation in proteus