Question

4. In this problem you will use CodeWarrior to develop the code to implement a three-light...

4. In this problem you will use CodeWarrior to develop the code to implement a three-light traffic signal. The program should do the following:

a. Turn on a green LED attached to Port B bit 2 for 60 seconds,

b. Turn off the green LED and turn on a yellow LED attached to Port B bit 1 for 30 seconds,

c. Turn off the yellow LED and turn on a red LED attached to Port B bit 0 for 60 seconds,

d. Turn off the red LED and repeat steps a through d continuously.

Start up CodeWarrior and configure it to run in the normal way for an absolute assembler in Full Chip Simulation mode. The code for a 1 ms delay loop is below: ldy #6000 loop: dey bne loop

Some useful instructions are on the next pages. If you think you need some instructions that don’t appear on the following pages just ask.

Note that you can test your code using CodeWarrior by entering small numbers for the loops (e.g., 6 in place of 6000) and stepping through your code in simulation mode to see if the appropriate bits are set and cleared at Port B. Be sure to replace the smaller numbers with the correct ones before submitting your solution.

Watch out for error messages, particularly relating to putting big numbers in small registers (e.g., >255 in an 8-bit register, or >65,535 in a 16-bit register).

When you’ve finished, save your CodeWarrior .asm file and send it to me along with your completed exam. Also cut and paste your code below, just in case.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

int red =10;

int yellow=9;

int green=8;

void setup(){
    pinMode(red, OUTPUT);
    pinMode(yellow, OUTPUT);
    pinMode(green, OUTPUT);
}
void loop(){
    changeLights();
    delay(60000);
}

void changeLights(){
    // green on, yellow on for 60 seconds
    digitalWrite(green, HIGH);
    delay(60000);

    // turn off green, then turn yellow on for 30 seconds
    digitalWrite(green, LOW);
    digitalWrite(yellow, HIGH);
    delay(30000);

    // turn off green and yellow, then turn on red
    digitalWrite(yellow, LOW);
    digitalWrite(green, LOW);
    digitalWrite(red, HIGH);
    delay(60000);
}
Add a comment
Know the answer?
Add Answer to:
4. In this problem you will use CodeWarrior to develop the code to implement a three-light...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use HCS12 assembly language only - not C code Using CodeWarrior to create a new project...

    Use HCS12 assembly language only - not C code Using CodeWarrior to create a new project that uses assembly language. Write an assembly program that turns on the red LED at the beginning. It switches to off 2 seconds later and switches back to on after three more seconds. (That is, it stays on for 2 seconds and off for 3 seconds.) This switching process lasts forever. Use a loop (or nested loops) for each of the 2/3-second delay where...

  • Having trouble with an automatic traffic light program. Red LED and Yellow LED won't show. We...

    Having trouble with an automatic traffic light program. Red LED and Yellow LED won't show. We are using a Dragon12 Plus 2 board, Code is below     #include C:\Users\schwarzenbar\Desktop\hcs12.inc       RED: EQU $10 ;PP4     GREEN:   EQU $40 ;PP6    org $2000    movb   #$FF, DDRP    bset   PTP, #RED     bset    DDRT,%00110000   ;PT4=Output for for IR Transmiter (IRTX)     bclr    DDRT,%00001000   ;PT3=Input pin for IR receiver (IRRX)     bclr    PTT,%00001000   ;PT4=0 to turn on IR...

  • Question 3: In class we showed how to simply light up an LED on our Teensy...

    Question 3: In class we showed how to simply light up an LED on our Teensy microcontroller. In fact, the procedure is similar for all processors including a simpler 8-bit ATmega 328P (a.k.a Arduino Uno) For purposes of this exercise, let's say that the ATmega328 has 4 regular GPIO ports; A, B, C, and D, each with 8 pins. Every GPIO port has three registers (outlined in table below) PORTX: used to write output on a pin on port X...

  • Can someone please help me with this problem? We are using CodeWarrior to write this program...

    Can someone please help me with this problem? We are using CodeWarrior to write this program in assembly language. The array sample contains eight 8-bit signed binary numbers (integers) as shown below. Write a program which stores the negative numbers in the array nelements, computes the sum of the positive numbens to be stored in the variable psum and stores the number of the positive numbers in the variable pnumber. Note that a zero is ther positive nor negative. Your...

  • Implement the following statements using MS430 assembly instructions. You may use more than one, ...

    Implement the following statements using MS430 assembly instructions. You may use more than one, but you should minimize the number of instructions required. You can use both native and emulated instructions. Use hex notation for all numbers 1. (a) Move the word located in register R14 to R15 (b) Increment the word in R6 by 2. (c) Perform a bitwise ANDing of the word located at address 0x0240 with the datum in R15, placing the results in R15. (d) Rotate...

  • Simulate a Sensor to control an alarm Before you attempt this assignment, it is suggested you...

    Simulate a Sensor to control an alarm Before you attempt this assignment, it is suggested you understand circuits (and the Arduino code) 1B and 1C. Sensor That being said, in this assignment, we’ll be mimicking an Infrared Sensor (detects objects) by utilizing the potentiometer. The potentiometer will provide us voltage potential that we can vary from 0V to 5V (similar to 1B). This voltage potential represents the output of a sensor. Assume the sensor cannot detect anything beyond 10 yards....

  • Application Problem: Answer the following questions at the bottom of the worksheet: You are configuring a...

    Application Problem: Answer the following questions at the bottom of the worksheet: You are configuring a microcontroller (uC) to sample a signal connected to an input pin. Part of the initial setup requires that you clear (turn off) bits #17 and #2 in a 32-bit register, while leaving all other bits unchanged. To work with specific bits, we typically use a second number, called a mask, which has the bit positions we need to alter set to 1, and all...

  • Assignment 2: Simulate a Sensor to control an alarm Before you attempt this assignment, it is...

    Assignment 2: Simulate a Sensor to control an alarm Before you attempt this assignment, it is suggested you understand circuits (and the Arduino code) 1B and 1C. Sensor That being said, in this assignment, we’ll be mimicking an Infrared Sensor (detects objects) by utilizing the potentiometer. The potentiometer will provide us voltage potential that we can vary from 0V to 5V (similar to 1B). This voltage potential represents the output of a sensor. Assume the sensor cannot detect anything beyond...

  • I need help with doing these tasks for code composer Lab 3 - Branching, Push Button...

    I need help with doing these tasks for code composer Lab 3 - Branching, Push Button and LEDs-Reading Assignment in this lab, we are going to control a LED via a push button- using general purpose digital 10 for both input (button) and output (LED) on port 1 - using Code Composer Studio. Furthermore, we are going to use a branch instruction to create an IF-ELSE structure in assembly to determine if the LED should be lit up based on...

  • 1a) We want you to feel comfortable reading documentation to understand the operation of a device....

    1a) We want you to feel comfortable reading documentation to understand the operation of a device. To that end, open the ATmega328/P datasheet linked on our website from the Tools and Links Page. Go to section 18.2 and read over pages 98-99. Note that "toggle" means flip to its opposite value, regardless of current value. What effect does writing a 1 to a PIN register bit have? Consider, how this might be used to generate the E signal pulse in...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT