100% found this document useful (1 vote)
2K views

Assignment 2

The C program displays the student's BITS ID on the first row of the LCD and the voltage from a potentiometer connected to an ADC pin on the second row. It initializes the LCD and ADC, reads the ADC value continuously, converts it to voltage, and displays the voltage on the second row. The student provides screenshots demonstrating the program's output on the LCD displaying their BITS ID and measured voltage value.

Uploaded by

RAHUL AGARWAL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
2K views

Assignment 2

The C program displays the student's BITS ID on the first row of the LCD and the voltage from a potentiometer connected to an ADC pin on the second row. It initializes the LCD and ADC, reads the ADC value continuously, converts it to voltage, and displays the voltage on the second row. The student provides screenshots demonstrating the program's output on the LCD displaying their BITS ID and measured voltage value.

Uploaded by

RAHUL AGARWAL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Q.1.

Write a C program for displaying your BITS ID on 1st Row and voltage difference
between the terminals of the potentiometer on 2 nd row of LCD Display present in the
LPC2378 kit. The Potentiometer is connected to AD0.0 pin of LPC2378. This program is to be
done using remote lab and Keil uV4 . Capture the screenshot of the LCD display showing
your BITS ID and voltage value. Give suitable screen shots of the KEIL IDE-in debug mode to
demonstrate the desired outputs. Ensure that the screenshot captures system time & day.
Ans : 1
C program for displaying the requested information on the LCD display of LPC2378 kit:

#include <LPC23xx.h>
#include <stdio.h>
#include <stdlib.h>
#include "lcd.h"

int main() {
// Initialize ADC
PINSEL1 |= (1 << 14); // Select AD0.0 pin
AD0CR = (1 << 0) | // Select channel 0
(1 << 21) | // Enable ADC
(10 << 8); // Set ADC clock to 4.5 MHz
// Initialize LCD
lcd_init();
// Display first name on first row
lcd_gotoxy(0, 0);
lcd_puts("Rahul (2022HT80055)");
// Read voltage difference from potentiometer and display on second row
while (1) {
AD0CR |= (1 << 24); // Start conversion
while (!(AD0GDR & (1 << 31))); // Wait for conversion to finish
unsigned int value = (AD0GDR >> 6) & 0x3FF; // Get 10-bit ADC value
float voltage = (float)value * 3.3 / 1023.0; // Convert to voltage
char str[16];
sprintf(str, "Voltage=%.2fV", voltage);
lcd_gotoxy(0, 1);
lcd_puts(str);
}
}

Q.2. Answer the following questions related to LPC2378:


a) What is the smallest change in input voltage that the ADC can detect? (+Vref =3.3 V) [1]
Ans : The smallest change in input voltage that the ADC can detect is determined by its
resolution, which is 10 bits in this case. The input voltage range is 0 to +Vref, which is 3.3V.
Therefore, the smallest change in input voltage that the ADC can detect is: Smallest voltage
change = Vref / 2^10 – 1 = 3.3/1023 = 3.23Mv

b) What is the maximum clock frequency needed by ADC of LPC2378? [1]


Ans : The maximum clock frequency needed by the ADC of LPC2378 is 13.5 MHz. However,
the ADC clock frequency can be set to a lower value to reduce power consumption or
increase accuracy.
Explanation: The ADC needs a clock signal to operate, and the maximum clock frequency it
can handle is 13.5 million times per second. However, we can set the clock frequency to a
lower value if we want to save power or improve accuracy.

c) Give the steps to program timer for 2 second delay generation with calculation. Assume
CCLK=48MHz.
Ans : To program the timer for a 2 second delay generation with CLK=48MHz, we need to
calculate the timer interval using the following formula:
Timer interval = (Delay time / Clock period) - 1
where Delay time is the desired delay in seconds, and
Clock period is the period of the system clock, which is 1/CCLK.
Substituting the values, we get:
Timer interval =2/(1/48,000,000)−1=95,999,999
The maximum value that can be loaded into the timer register is 2^32-1, which is greater
than the calculated value. Therefore, we can use any timer in LPC2378 to generate a 2
second delay by loading the calculated value into its match register and configuring it to
generate an interrupt when the timer value matches the match register value.
Explanation:
To generate a 2 second delay using a timer in LPC2378, we need to calculate the value that
needs to be loaded into the timer register using a simple formula that takes into account the
system clock frequency and the desired delay time. Once we have the timer value, we can
configure the timer to generate an interrupt when it reaches the match value, which will
signal that the 2 second delay has elapsed.

You might also like