Provide detils and explination as a coments In this lab you will become familiar
ID: 3852961 • Letter: P
Question
Provide detils and explination as a coments
In this lab you will become familiar with the basic use and configuration of timers. You will learn how to configure and access the Timer/Counter0 registers to create a delay function. Much like the delay() function provided with the Arduino libraries. Throughout this procedure you will apply C++ pointers to access the ATMega328P registers. Upon completion of this lab, students will be able to: List the timers and their associated registers Describe the Normal mode of the AVR timers Program the AVR timers in C++ to generate time delays To achieve the learning objectives, students are expected to complete the following: attend lecture attend lab review video lectures Create a function that takes in a parameter to specify the delay time (in ms). The function uses timers to create a delay for the duration (in milliseconds) passed in. The function prototype is given below. //This function takes in a parameter to specify the time (in ms) to create a delay. void delay_generic(unsigned int time_ms): Use your function to blink LED connected to pin 13 for the duration specified by the time_ms parameter.Explanation / Answer
The function and it's implementation for requesting time delay in C is as follows.Here goes the code:
timede.c
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
void req( int sec )
{
#ifdef _WIN32
Sleep( 1000 * sec );
#else
sleep( sec );
#endif
}
int main( int args, char **argU)
{
int time = 3;
while( time )
{
--time;
req( 3 );
}
return 0;
}
Please rate the answer if it helped.....Thankyou
Hope it helps.....
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.