Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The task of this exercise is to create a program and successfully download it to a dragon12-light board. Using a CodeWarrior_CProgramShell.txt and the HCS12 Microcontrollers

The task of this exercise is to create a program and successfully download it to a dragon12-light board. Using a CodeWarrior_CProgramShell.txt and the HCS12 Microcontrollers and Embedded Systems, 1st Edition. I am struggling to determine the condition of the exercise requirement and keep getting error messages. The CodeWarrior_CProgramShell.txt below is a guideline of how to create a program and successfully download to the dragon12-light board. I need help to solve this problem and it is due tomorrow night? Thank you.

Objective: Used the port H as an input port and port B as an output port and download the program to the dragon12-Light boards.

When both DIP switches #8 and #1 are high, turn on all LEDS.

When both DIP switches #8 and #1 are low, turn off all LEDs

When DIP switch #8 is high and #1 is low, turn on all the even numbered LEDs.

When DIP switch #1 is high and #8 is low, turn on all the odd numbered LEDs.

Your program must to read DIP switches and turn on/off corresponding LRDs continuously until a Reset.

//*****************************************************************

// Include derivative-specific definitions

//*****************************************************************

//The microcontroller chip used by Dragon12-Light boards

#include /* derivative information */

//*****************************************************************

// Gloable Variables

//*****************************************************************

//*****************************************************************

// Function Prototype

//*****************************************************************

void InitSwitches(void);

void InitLEDs(void);

void DelayTime(unsigned int,unsigned int);

//*****************************************************************

// Main program section

//*****************************************************************

void main(void)

{

/* put your own code here */

InitSwitches();

InitLEDs();

//do this forever

for (;;)

{

unsigned char x;

x = PTH; //get data from DIP Switches via. PTH

DelayTime(1, 4000); //optional, delay some time

PORTB = x; //and send it to PORTB LEDs

DelayTime(1, 4000); //optional

}

}

//*****************************************************************

// Function: InitSwitches

//*****************************************************************

void InitSwitches(void)

{

DDRH = 0x0; //make port PTH an input port for reading DIP switches

}

//*****************************************************************

// Function: InitLEDs

//*****************************************************************

void InitLEDs(void)

{

//LEDs are connected to PORTB on Dragon12-Light

DDRB = 0xFF; //make PORTB an output for LEDs

//PTP0, PTP1, PTP2 and PTP3 of port PTP control the 4 units of the seven seg. display

//GRB LED is controlled by PP4-PP6: PP4=1, red; PP5=1, blue; PP6=1, green

DDRP = 0xFF; //make port PTP an output port

PTP = 0x4F; //make PTP0-PTP3 high to disable the seven seg. dispaly

//and make PTP6 high to turn on green RGB LED

}

//*****************************************************************

// Function: DelayTime

//*****************************************************************

//provide milli seconds delay

void DelayTime(unsigned int i_limit, unsigned int j_limit)

{

unsigned int i;

unsigned int j;

for(i=0;i

for(j=0;j

//do nothing

}

}

}

//*****************************************************************

// Interrupt Service Routines

//*****************************************************************

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

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

Students also viewed these Databases questions