View the step-by-step solution to:

C SC 230 - Spring 2013 - Assignment 3 - Total Marks = 100 (1) Flowchart is due March 6th in the lecture; (2) Code is due Monday, March 11 by 11:

Hi..This is the traffic lights project which is about assembly language...when you finish it..could you sent it to me as ARM .S file..
And the assembly includes three files: 1. Project explanation 2, initial code 3. some practise code similar to project
to simulate the can download ARMsim# 1.91 software:
then run the software, go to file, click preferences, then check both option. then go to view, click pluginsUI, then you can see the simulate board
Page 1 of 14 C SC 230 – Spring 2013 – Assignment 3 - Total Marks = 100 (1) Flowchart is due March 6th in the lecture; (2) Code is due Monday, March 11 by 11:55pm by electronic submission The goal of this assignment is to develop your competence at writing good, robust and elegant ARM code, plus downloading it to a board to get real hardware to cooperate with you. Finally you will be giving a demonstration and receive one-on-one feedback on your work, in the hope that we can provide you with a constructive learning experience and give you some good suggestions for the future. It is imperative to check the web pages after the posting of this assignment, as more details and/or clarifica- tions will be added as necessary to the specifications in this document. The assignment overall comprises the following main tasks: 1. Write a new program for the control of a small embedded system, following the specifications. Test the program using the simulator with a graphics plug-in for the output peripherals. 2. Download the program to run on the Embest board with the real physical peripherals. 3. Give a demo of your work in person, discuss your design choices and receive feedback. 4. Prepare good documentation for your design and implementation decisions and for your code. 1. The Story Line You are to write an ARM assembly language program that simulates the operation of a traffic light controller for an intersection, where the movements of both cars and pedestrians are controlled by lights and buttons. Figure 1 illustrates the intersection of a major street, labelled “High Street”, with a secondary road, labelled “Side Road”. There is a traffic light at every corner. The light gives more crossing time to the vehicles on High Street than to the vehicles on Side Road, to take different volumes of traffic into account. The traffic light controller goes through a main cycle which allows traffic to flow on High Street for a minimum of 12 seconds and a maximum of 18 seconds. It then changes to allow traffic to flow on Side Road for 6 seconds. This two cycles repeat themselves forever in this manner. On every pole holding a traffic light there is also a button, which can be pressed by pedestrians. If any of the four buttons for pedestrians are pressed, the car traffic cycles are eventually suspended and all vehicle traffic stops, allowing pedestrians to cross in all four directions for a maximum of 6 seconds. The four buttons are labelled “ Ps1 ”, “ Ps2 ”, “ Ph1 ”, and “ Ph2 ”, depending on their position with respect to the intersection. As an High Street High Street Side Road Side Road Ps1 Figure 1: Diagram of the Road Intersection Ps2 Ph1 Ph2
Background image of page 01
Page 2 of 14 aid to pedestrians, the traffic light also shows the countdown in seconds of the time available for crossing. The overall program for the simulation is started by a user who can also decides when to exit the program. 2. Functionality 2.1 Starting Up When the program starts execution, the following should happen: 1. Both LED lights should be turned on. 2. On the LCD screen the student number should appear on line 1 as in: “Student Number V00123456 ”. 3. The 8-Segment Display should light the point segment (labelled “P”, see below). 4. The program waits for the user to press the left black button to start the simulation. When the left black button is pushed, the simulation of the traffic lights should start (see below), together with its outputs. 5. Pressing the right black button before pressing the left one, that is, before starting the overall simulation, should exit the program. The LCD screen is cleared and all lights and displays are turned off. 6. Pressing any blue button before pressing the left black button should have no effect. 2.2 Ending the simulation and the program. A user can end the program execution by pressing the right black button. The following events should be pro- grammed within the exiting module. 1. Pressing the right black button while the simulation is in progress should cause the program to end. How- ever this event is recognized and acted upon only at certain points in the simulation cycle, namely the same points when the pedestrian buttons are also being recognized (see details on pedestrian polling and cycle below). 2. Ending the program implies: (a) returning to main ; (b) clearing the LCD screen and then printing a final message; (c) turning off all lights and displays; (d) showing the cleared board for at least 2 seconds before exiting. 2.3 The Simulation. The events for the traffic lights simulation include a cycle of red and green lights alternating between High Street and Side Road, with High Street using the longest time. Pedestrians can press buttons to request a crossing light. When the request is accepted, by polling the appropriate buttons, lights for car traffic turn to red in all directions and pedestrians are allowed to cross both High Street and Side Road. A display shows the number of seconds remaining in the pedestrian crossing cycle. The car cycle then resumes. During the car cycle, the setting of the four traffic lights are displayed in a (crude) graphical form on the LCD screen in a given format, to show the user the current stage of the simula- tion. Figure 2 can be formally described as an Algorithm State Machine (ASM) chart. It represents the car traffic cycle and the patterns of expected outputs. The explanation follows. The colours used in the diagram do not have any semantic meaning. We use a triples notation to represent the traffic light settings. A triple has the form L h / L s / L p where L h spec- ifies the lights displayed for traffic on High Street, L s the lights for traffic on Side Road, and L p the lights shown to pedestrians. The possible values for L h and L s are: “ R ” (red is displayed), “ Y ” (yellow is dis- played), “ G ” (green is displayed) and “ _ ” (no light is displayed). The possibilities for L p (displayed as graphic pictures to the pedestrians) are “ W ” meaning “wait -do not cross”, “ X ” meaning “cross now” and “ ! meaning “hurry up, the traffic is about to resume”.
Background image of page 02
Show entire document
@ SWI_Instructions.s - Introduction to SWI instructions in ARMSim# @ @ Date: 5 March 2012 @ Written by: Dean Pucsek @ This sample code does the following: @ 1. Get a "secret" value @ 2. Print a message to the LCD @ 3. Check to see if (and which) a blue button has been pressed @ 4. Compare the button press to the secret number @ If the numbers are the same @ 5. Call the strobe light subroutine @ 6. Exit @ Else @ 5. Go back to step 3 @ SWI Codes (Taken from the ARMSim# manual) .equ SWI_SET_LED, 0x201 @ LEDs on/off .equ SWI_CHECK_BLUE, 0x203 @ Check press blue button .equ SWI_DRAW_STRING, 0x204 @ Display a string on LCD .equ SWI_DRAW_INTEGER, 0x205 @ Display integer .equ SWI_CLEAR_DISPLAY, 0x206 @ Clear LCD .equ SWI_CLEAR_LINE, 0x208 @ Clear a line on LCD .equ SWI_EXIT, 0x11 @ Terminate program .equ SWI_GET_TICKS, 0x6d @ Get current number of CPU ticks @ Patterns for the LED lights .equ NO_LED, 0x00 .equ RIGHT_LED, 0x01 .equ LEFT_LED, 0x02 @ Patterns for the blue buttons .equ BLUE_KEY_00, 0x0001 @ Button 0 .equ BLUE_KEY_01, 0x0002 @ Button 1 .equ BLUE_KEY_02, 0x0004 @ Button 2 .equ BLUE_KEY_03, 0x0008 @ Button 3 @ Time delays (values are in milliseconds) .equ ONE_SEC, 1000 .equ TWO_SEC, 2000 .equ THREE_SEC, 3000 .equ FOUR_SEC, 4000 .equ FIVE_SEC, 5000 .text .global _start _start: swi SWI_CLEAR_DISPLAY @ Clear the LCD screen mov r0,#NO_LED @ Set argument to SWI_SETLED to "both LEDs off" swi SWI_SET_LED @ Set the LEDs accordingly InfiniteLoop: @ Get a "secret" number swi SWI_GET_TICKS and r0, r0, #0x3 @ Keep only the lowest two bits (values 0-3) ldr r1, =SecretNumber str r0, [r1]
Background image of page 1
@ Clear the LCD screen swi SWI_CLEAR_DISPLAY @ Print a message on the LCD screen (line 1, column 4) mov r0,#4 @ Column number mov r1,#1 @ Line number ldr r2,=PickANumber @ Pointer to message swi SWI_DRAW_STRING @ Draw to the LCD screen @ Wait three seconds for a button press ldr r3, =THREE_SEC bl Wait @ Check to see if a blue button has been pressed swi SWI_CHECK_BLUE cmp r0, #BLUE_KEY_00 moveq r0, #0 bleq HandleButtonPress cmp r0, #BLUE_KEY_01 moveq r0, #1 bleq HandleButtonPress cmp r0, #BLUE_KEY_02 moveq r0, #2 bleq HandleButtonPress cmp r0, #BLUE_KEY_03 moveq r0, #3 bleq HandleButtonPress @ Start again bal InfiniteLoop @ Exit program Exit: swi SWI_EXIT @ Subroutine: HandleButtonPress @ Input: r0 - Number of pressed blue button @ Output: None @ @ Call the appropriate light flsashing subroutine according to the button @ button pressed and secret number. HandleButtonPress: stmfd sp!, {r0-r1,lr} ldr r1, =SecretNumber ldr r1, [r1] cmp r0, r1 @ Was the button pressed the same as the secret number? bleq BlinkLEDs blne DisplayError ldmfd sp!, {r0-r1,pc} @ Subroutine: BlinkLEDs @ Input: None @ Output: None @
Background image of page 2
Show entire document
@ CSC230 -- Traffic Light simulation program @ Latest edition: Fall 2011 @ Author: Micaela Serra @ Modified by: Captain Picard <---- PUT YOUR NAME AND ID HERE!!!! @===== STAGE 0 @ Sets initial outputs and screen for INIT @ Calls StartSim to start the simulation, @ polls for left black button, returns to main to exit simulation .equ SWI_EXIT, 0x11 @terminate program @ swi codes for using the Embest board .equ SWI_SETSEG8, 0x200 @display on 8 Segment .equ SWI_SETLED, 0x201 @LEDs on/off .equ SWI_CheckBlack, 0x202 @check press Black button .equ SWI_CheckBlue, 0x203 @check press Blue button .equ SWI_DRAW_STRING, 0x204 @display a string on LCD .equ SWI_DRAW_INT, 0x205 @display an int on LCD .equ SWI_CLEAR_DISPLAY, 0x206 @clear LCD .equ SWI_DRAW_CHAR, 0x207 @display a char on LCD .equ SWI_CLEAR_LINE, 0x208 @clear a line on LCD .equ SEG_A, 0x80 @ patterns for 8 segment display .equ SEG_B, 0x40 .equ SEG_C, 0x20 .equ SEG_D, 0x08 .equ SEG_E, 0x04 .equ SEG_F, 0x02 .equ SEG_G, 0x01 .equ SEG_P, 0x10 .equ LEFT_LED, 0x02 @patterns for LED lights .equ RIGHT_LED, 0x01 .equ BOTH_LED, 0x03 .equ NO_LED, 0x00 .equ LEFT_BLACK_BUTTON, 0x02 @ bit patterns for black buttons .equ RIGHT_BLACK_BUTTON, 0x01 @ bit patterns for blue keys .equ Ph1, 0x0100 @ =8 .equ Ph2, 0x0200 @ =9 .equ Ps1, 0x0400 @ =10 .equ Ps2, 0x0800 @ =11 @ timing related .equ SWI_GetTicks, 0x6d @get current time .equ EmbestTimerMask, 0x7fff @ 15 bit mask for Embest timer @(2^15) -1 = 32,767 .equ OneSecond, 1000 @ Time intervals .equ TwoSecond, 2000 @define the 2 streets @ .equ MAIN_STREET 0 @ .equ SIDE_STREET 1 .text .global _start @===== The entry point of the program _start: @ initialize all outputs BL Init @ void Init () @ Check for left black button press to start simulation RepeatTillBlackLeft: swi SWI_CheckBlack cmp r0, #LEFT_BLACK_BUTTON @ start of simulation
Background image of page 1
beq StrS cmp r0, #RIGHT_BLACK_BUTTON @ stop simulation beq StpS bne RepeatTillBlackLeft StrS: BL StartSim @else start simulation: void StartSim() @ on return here, the right black button was pressed StpS: BL EndSim @clear board: void EndSim() EndTrafficLight: swi SWI_EXIT @ === Init ( )-->void @ Inputs: none @ Results: none @ Description: @ both LED lights on @ 8-segment = point only @ LCD = ID only Init: stmfd sp!,{r1-r10,lr} @ LCD = ID on line 1 mov r1, #0 @ r1 = row mov r0, #0 @ r0 = column ldr r2, =lineID @ identification swi SWI_DRAW_STRING @ both LED on mov r0, #BOTH_LED @LEDs on swi SWI_SETLED @ display point only on 8-segment mov r0, #10 @8-segment pattern off mov r1,#1 @point on BL Display8Segment DoneInit: LDMFD sp!,{r1-r10,pc} @===== EndSim() @ Inputs: none @ Results: none @ Description: @ Clear the board and display the last message EndSim: stmfd sp!, {r0-r2,lr} mov r0, #10 @8-segment pattern off mov r1,#0 BL Display8Segment @Display8Segment(R0:number;R1:point) mov r0, #NO_LED swi SWI_SETLED swi SWI_CLEAR_DISPLAY mov r0, #5 mov r1, #7 ldr r2, =Goodbye swi SWI_DRAW_STRING @ display goodbye message on line 7 ldmfd sp!, {r0-r2,pc} @ === StartSim ( )-->void @ Inputs: none @ Results: none @ Description: @ XXX StartSim: stmfd sp!,{r1-r10,lr}
Background image of page 2
Show entire document

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.


Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question