Question: 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"

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 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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!