Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C program for the ATmega328P to generate a Pulse Width Modulation (PWM) output using counter/timer. The PWM signal generated cannot directly drive a

image text in transcribed
Write a C program for the ATmega328P to generate a Pulse Width Modulation (PWM) output using counter/timer. The PWM signal generated cannot directly drive a motor, i.e., it cannot provide the required current due to current limitations in the MCU I/O pins. The signal has to be connected to a motor driver that is available in the lab. The use of delays to generate PWM are NOT allowed in this lab. You can use delays only to de-bounce a button-press and to wait for long periods of time, if needed. You will observe the control signal through an oscilloscope. Write a function called setPWMtimer1 that accepts two parameters, frequency and duty cycle. Upon receiving the two parameters, the function setPWM sets up timer1 for its operation as per the parameters. If for some reason, the values are beyond what could be achieved using hardware PWM considering internal clocks only, then the function should return -1; otherwise, to indicate that the PWM was setup successfully, the function should return bits (an unsigned char containing the bits of the course source CS12, c.11, C510). Now, write two more functions called startTimers and stop Timer1. Function startTimer1, will simply start the timer while stopTimer1 will stop it, without affecting any other configuration. Also note that not all possible values of frequencies and duty cycles are possible. In order to avoid confusing the user of the function, kindly write what values will work as comment

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

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions

Question

What is the best time for a firm to develop its business model?

Answered: 1 week ago

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago