Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Turn LED0 off and on with a period of 1 second using c++ Complete the implementation of the setupLed0, turnOnLed0, and turnOffLed0 functions. The hash-tags

Turn LED0 off and on with a period of 1 second using c++

Complete the implementation of the setupLed0, turnOnLed0, and turnOffLed0 functions. The hash-tags for this exercise are: #cab202, and #cab202blinkLed0.

By completing this exercise you will develop the ability to control one of the LEDs mounted on the Teensy circuit board, including:

Controlling the CPU clock speed to enable accurate timing.

Setting up a data direction register to enable digital output to the LED.

Writing data to an output register to control the LED.

To complete the program, follow the instructions detailed in the in-line comments in the skeleton code below.

Notes

Use this test driver to implement and test your function prior to submission.

#include #include #include #include

void setupLed0( void ) { // (a) Set the CPU speed to 8MHz (you must also be compiling at 8MHz).

// (b) Configure the data direction register for Port B to use LED0 for // output. The data direction for LED0 is controlled by Pin 2. No other // pins should be affected.

// (c) Turn off LED0 (and all other outputs connected to Port B) by // clearing all bits in the Port B output register. }

void turnOnLed0( void ) { // (d) Set pin 2 of the Port B output register. No other pins should be // affected. }

void turnOffLed0( void ) { // (e) Clear pin 2 of the Port B output register. No other pins should be // affected. }

int main(void) { setupLed0();

while ( 1 ) { turnOnLed0(); _delay_ms(500);

turnOffLed0(); _delay_ms(500); }

return 0; }

Use avr-gcc to compile the test driver, convert it to a .hex file, and download the .hex file to your Teensy. If the program is implemented correctly, you should see LED0 alternately flash on and off with a period of 1 second.

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

Database Marketing The New Profit Frontier

Authors: Ed Burnett

1st Edition

0964535629, 978-0964535626

More Books

Students also viewed these Databases questions

Question

Assessment of skills and interests.

Answered: 1 week ago

Question

Psychological, financial, and career counseling.

Answered: 1 week ago