Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Using Delays The library util/delay.h implements the delay function _delay_ms(). This function can cause a delay in milliseconds. For example, to introduce a 20ms delay

Using Delays

The library util/delay.h implements the delay function _delay_ms(). This function can cause a delay in milliseconds. For example, to introduce a 20ms delay the function is called as follows:

_delay_ms(20);

void my_delay(int ms)

{

int i;

for(i = 0; i

_delay_ms(1);

}

However, this function cannot introduce delays longer than 50 ms. As a work around, the following custom function is created for you in order to introduce delays of virtually any length.

This function can be called from the main subroutine whenever needed! For example, to introduce a delay of 2 seconds, the function can be called as follows:

my_delay(2000);

You are requested to write a C program for the ATmega8 microcontroller. The microcontroller accepts 1-bit input (called speed), and produces a 4-bit output (called count). The output counts from 0 to F repeatedly, and is displayed on LEDs. However, the delay between each count is controlled by the input speed. The delay between counts is 1 second if speed is set, 0.5 seconds otherwise. The input and output MUST be accessed through PORTB only.

Use AtmelStudio and Proteus simulator to validate the program that you developed. Figure 1 illustrates how to add a switch from Proteus library.

image text in transcribed

Pre-Lab: You are requested to complete this pre-lab before coming the next lab session. Lab instructor will check and evaluate your work at the beginning of the lab session. 1. Using Delays The library util/delavh implements the delay function_delay ms . This function can cause a delay in milliseconds. For example, to introduce a 20ms delay the function is called as follows: delay_ms (20) However, this function cannot introduce delays longer than 50 ms, As a work around, the following custom function is created for you in order to introduce delays of virtually any length. void my_delay(int ms) int i; for (i= 0; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions