Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Freescale codewarrior program. From the directory on the left of the screen double click on main.c (under Sources) to see the default program shown below:

Freescale codewarrior program.

From the directory on the left of the screen double click on main.c (under Sources) to see the default program shown below:

// Example 4 // Flash an LED at the rate determined by a potentiometer

#include // common defines and macros

#include // derivative information

#pragma LINK_INFO DERIVATIVE "mc9s12xet256"

void MSDelay(unsigned int itime);

void main(void) {

int delay;

DDRH = 0b00000001; // enable LED

DDRP = 0b11111111; // enable potentiometer (knob)

for(;;) {

delay = PTP;

if (delay < 1) { // delays of zero are BAD!

delay = 1;

}

PTH = 1;

MSDelay(delay);

PTH = 0;

MSDelay(delay);

} /* loop forever */

}

void MSDelay(unsigned int itime){

unsigned int i; unsigned int j;

for(i=0;i

for(j=0;j<4000;j++);

}

Start the program by selecting Project|Debug from the top menu (or just press F5). This will compile your program, and start the debugger. In order to see what your program is doing, select Component|Open|Visualizationtool from the menu strip at the top of the debug window and click OK:

This opens a blank Visualization Tool window.

Since we will be using an endless loop in our program, we will need to adjust the cycle time for our simulation. Right-click your mouse anywhere in the Visualization Tool window and select Properties. Set the Refresh Mode to Periodical, and set the Refresh Time to 1.

Right-click your mouse inside the Visualization Tool window, select Add New Instrument|LED, and click anywhere on the display to pin it down.

To connect this control to your program, you need to assign the control to Port H (hex memory address $0260). Double click on the LED control to bring up the property sheet, add 0x0260 to the port address, set the Height and Width to 50, and press return.

Do the same thing for the Knob control and assign the control to Port P (hex memory address $0258). Double click on the Knob control to bring up the property sheet, add 0x0258 to the port address, and press return.

(You can save yourself some work in the future by selecting File|Save Configuration from the menu bar in the Debug window.) To see the program run, select Run|Restart from the menu bar in the Debug window. (You also may need to toggle the Visualization screen from Edit Mode to Display Mode.)

Now its your turn. Modify the existing code by replacing the LED with an Analog Dial control. Set it up so that the value of the Potentiometer (Knob) control is displayed on the Dial (Analog) control. No delays are required for this modification.

Example:

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

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions

Question

Prepare a short profile of Lucy Clifford ?

Answered: 1 week ago

Question

Prepare a short profile of Rosa parks?

Answered: 1 week ago

Question

Prepare a short profile of victor marie hugo ?

Answered: 1 week ago

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago