PINK (MUX0-MUX4): These five bits are for telling the input channel. LIGHT GREEN (ADATE): This bit must be set for the ADC to run continuously (free running mode). Since we want to have reference voltage 2.56V, REFS0 and REFS1 both should be set, by the table. RED (ADEN): This bit has to be set for enabling the ADC feature of ATMEGA.īLUE(REFS1,REFS0): These two bits are used to set the reference voltage (or max input voltage we are going to give). These are the only four things we need to know to getting started with ADC. All the above four features are set by two registers. Since we are using the internal clock of 1MHZ, the clock of ADC will be (1000000/128). For lesser ADC clock we are setting the presale of ADC to maximum value (128). So for better accuracy of digital output we have to choose lesser frequency. For any ADC, frequency of conversion (Analog value to Digital value) and accuracy of digital output are inversely proportional.
#Codevisionavr assembly free
The controller has a trigger conversion feature, that means ADC conversion takes place only after an external trigger, since we don’t want that we need to set the registers for the ADC to run in continuous free running mode.Ĥ.
So we can set up maximum value or reference of ADC to 2.5V.ģ. Since we are measuring room temperature, we don’t really need values beyond hundred degrees (1000mV output of LM35). Now we need to set the register of ADC based on the following terms:ġ.First of all we need to enable the ADC feature in ADC.Ģ. So for every 5mV increment in the input we will have a increment of one at digital output. We are going to choose channel 0 or PIN0 of PORTA. In ATMEGA32A, the ADC is of 10 bit resolution, so the controller can detect a sense a minimum change of Vref/2^10, so if the reference voltage is 5V we get a digital output increment for every 5/2^10 = 5mV. To filter out the noise a capacitor needs to be placed at the output of the sensor as shown in figure.īefore moving ahead we need to talk about ADC of ATMEGA32A. In ATMEGA32A, we can give Analog input to any of eight channels of PORTA, it doesn’t matter which channel we choose as all are same. So from mere observation from above table we are connecting 10 pins of LCD to controller in which 8 pins are data pins and 2 pins for control. The voltage output provided by sensor is not completely linear it will be a noisy one. In the circuit you can see we have used 8bit communication (D0-D7) however this is not a compulsory, we can use 4bit communication (D4-D7) but with 4 bit communication program becomes a bit complex so I have choosed the 8 bit communication. PIN5 or RW (Read/Write) -ground (puts LCD in read mode eases the communication for user) PIN4 or RS (Register Selection) -PD6 of uC PIN3 or VEE-ground (gives maximum contrast best for a beginner) The connections which are done for LCD are given below: We just need to control ENABLE and RS pins to send characters and data accordingly. This puts LCD in highest contrast and read mode. The contrast bit and READ/WRITE are not often used so they can be shorted to ground. In the circuit, you can observe I have only took two control pins as this give the flexibility of better understanding. Now in the 14 pins there are 8 data pins (7-14 or D0-D7), 2 power supply pins (1&2 or VSS&VDD or gnd&+5v), 3 rd pin for contrast control (VEE-controls how thick the characters should be shown), 3 control pins (RS&RW&E).
One can power or leave the back light pins. In 16x2 LCD there are 16 pins over all if there is a back light, if there is no back light there will be 14 pins. Here one should remember to disable the JTAG communication in PORTC ot ATMEGA by changing the fuse bytes, if one wants to use the PORTC as a normal communication port. In the circuit, PORTB of ATMEGA32 is connected to data port of LCD.