Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me with this lab! I need code for the pwm.c file only where is says your code here Part 2: Servo control programming

Please help me with this lab! I need code for the pwm.c file only where is says "your code here"

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Part 2: Servo control programming For this lab, you will need to use two provided library functions: gpio_write and delay_usec. (See the code in src/eecs388_lib.c). Using these functions, you should output the ON signal (5V) for a specific duty cycle duration, followed by the OFF signal until the PWM period elapsed. The project code you downloaded already includes the basic skeleton of the program, which will sweep different angles, each of which for about a 1 second duration. You will need to fill the servo function in the src/eecs 388_pwm.c to complete the lab. eecs388_lib.h eecs388_lib.c eecs388_pwm.c -#include #include "eecs388_lib.h" void gpio_mode(int gpio, int mode) { uint32_t val; if (mode == OUTPUT) { val = *(volatile uint32_t *) (GPIO_CTRL_ADDR + GPIO_OUTPUT_EN); val |= (1 #include 3 4 #include "eecs388_lib.h" 5 6 #define SERVO_PULSE_MAX 2400 /* 2400 us */ 7 #define SERVO_PULSE_MIN 544 /* 544 us */ 8 #define SERVO_PERIOD 20000 /* 20000 us (20ms) */ 9 10 11 * Generate a pwm signal 12 13 * Input: 14 @gpio gpio pin number 15 @pos degree [0,180] 16 */ 17 void servo(int gpio, int pos) 18 { 19 // YOUR CODE HERE 20 } 21 22 int main() 23 { 24 int gpio = PIN_19; 25 gpio_mode (gpio, OUTPUT); 26 27 while (1) { 28 for (int pos = 0; pos #include "eecs388_lib.h" void gpio_mode(int gpio, int mode) { uint32_t val; if (mode == OUTPUT) { val = *(volatile uint32_t *) (GPIO_CTRL_ADDR + GPIO_OUTPUT_EN); val |= (1 #include 3 4 #include "eecs388_lib.h" 5 6 #define SERVO_PULSE_MAX 2400 /* 2400 us */ 7 #define SERVO_PULSE_MIN 544 /* 544 us */ 8 #define SERVO_PERIOD 20000 /* 20000 us (20ms) */ 9 10 11 * Generate a pwm signal 12 13 * Input: 14 @gpio gpio pin number 15 @pos degree [0,180] 16 */ 17 void servo(int gpio, int pos) 18 { 19 // YOUR CODE HERE 20 } 21 22 int main() 23 { 24 int gpio = PIN_19; 25 gpio_mode (gpio, OUTPUT); 26 27 while (1) { 28 for (int pos = 0; pos

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions