#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <stdint.h>
ID: 3870597 • Letter: #
Question
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include "TM4C123GH6PM.h"
#include "ez123G.h"
char str[100];
int main(void)
{
PEZOBJ_LCD lcd;
uint16_t i = 0;
// GPIO Initialization and Configuration
// 1. Enable Clock on GPIOs
SYSCTL->RCGCGPIO |= 0x00;
// allow time for clock to stabilize
while ((SYSCTL->PRGPIO & 0x0D) != 0x0D) {};
// 2. Unlock PD7 and/or PF0 for TM4C 123G
GPIOD-> LOCK = 0x4C4F434B;
GPIOD -> CR |= 0x80;
// 3. Config AMSEL to disable analog function
GPIOA -> AMSEL = 0x00;
GPIOC -> AMSEL &= 0x9F;
GPIOD -> AMSEL = 0x00;
// 4. Config PCTL to select 0-GPIO
GPIOA -> PCTL = 0x00;
GPIOC -> PCTL &= 0x60;
GPIOD -> PCTL = 0x00;
// 5. Set AFSEL bits to 0
GPIOA -> DIR = 0x00;
GPIOC -> DIR |= 0x60;
GPIOD ->DIR = 0x80;
// 6. Set DIR to 0 for input, 1 for output
GPIOA ->AFSEL =0x00;
GPIOC -> AFSEL &= 0x60;
GPIOD -> AFSEL = 0x00;
// 7. Set PUE bits to 1 to enable internal pull-up (Skipped)
GPIOA -> PUR = 0x04;
GPIOA -> PUR= 0x08;
// 8. Set DEN bits to 1 to enable all pins
GPIOA -> DEN = 0x0Ci;
GPIOC -> DEN = 0x60i;
GPIOD ->DEN = 0x80i;
lcd = ezLCD_Create();
ezLCD_Connect_DataPort(lcd, GPIOD, PIN_3_0);
ezLCD_Connect_ENPin(lcd, GPIOE, PIN1);
ezLCD_Connect_RSPin(lcd, GPIOE, PIN2);
ezLCD_Connect_RWPin(lcd, GPIOE, PIN3);
ezLCD_Start(lcd);
ezLCD_LoadVerticalBargraphFonts(lcd);
ezLCD_ClearDisplay(lcd);
ezLCD_PrintString(lcd, "HELLO");
ezLCD_Position(lcd, 1,0);
ezLCD_PrintString(lcd, "EE-3450 TI Tiva");
while(1){
sprintf(str,"i = %d ", i);
ezLCD_Position(lcd, 0, 7);
ezLCD_PrintString(lcd, str);
ezLCD_DrawVerticalBG(lcd, 1, 6, 2, i%16);
i++;
timer_waitMillis(100);
}
}
need help to finish the code to fit the questions. thank you
Lab Experiments Using your embedded board to solve the following problems, and display the result on the character LCD display. Do not directly calculate and show the answer. You have to use loop statements to get it. 1. Calculate the Sum of Series Numbers Write a program in C to display the sum of series numbers. The series is: 4 68+120 2. Calculate the Sum, Average; Find the Maximum and Minimum Value from and Array Write a program in C to calculate the sum, average, and find the maximum and minimum values from an array as shown below: 1| int arrayt]- (10, 35, 65, 43, 32, 86, 44, 9, 18] Display the results on the LCD display as shown as below: (S: sum. M: maximum value, A: average, m: minimum value, x: your result)Explanation / Answer
1. Calculate sum of series
#include <stdio.h>
void main()
{
int i, num=120, even_sum = 0; // here num is the max number.
// i is the start number of the series here start number is 4
for (i = 4; i <= num; i++)
{
if (i % 2 == 0)// logic to get even numbers
even_sum = even_sum + i;
}
printf("Sum of numbers = %d ", even_sum);
}
Sample output:
Sum of numbers:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.