Writing an Embedded Controller. It usually consists of two parts – Initialization – A main loop More challenging than HW3 because HW3 is stateless, the.

Slides:



Advertisements
Similar presentations
Branches Two branch instructions:
Advertisements

CDA 3100 Recitation Week 8. Question 1.data A:.word 21,3,2,9,100,22,6,15,33,90.text.globl main main: la $a0, A li $a1, 17 li $a2, 10 jal funct li $v0,
Lecture 9: MIPS Instruction Set
CDA 3100 Recitation Week 15. What does the function f1 do:.data A:.word 10,21,45,8,100,15,29,12,3,19 B:.word 2,5,33,5,20,1,53,52,5,5 C:.word 6,8,5,4,5,22,53,12,33,89.text.globl.
SPIM and MIPS programming
MIPS Function Continued
1 Nested Procedures Procedures that don't call others are called leaf procedures, procedures that call others are called nested procedures. Problems may.
Ch. 8 Functions.
Input and Output CS 215 Lecture #20.
Writing an Embedded Controller. It usually consists of two parts – Initialization – A main loop Experience: – The main loop usually has to deal with many.
MIPS Coding. Exercise – the bubble sort 5/8/2015week04-3.ppt2.
Feb 18, 2009 Lecture 4-2 instruction set architecture (Part II of [Parhami]) MIPS encoding of instructions Spim simulator more examples of MIPS programming.
Instruction Representation II (1) Fall 2007 Lecture 10: Instruction Representation II.
1 Lab Session-III CSIT-120 Spring 2001 Revising Previous session Data input and output While loop Exercise Limits and Bounds GOTO SLIDE 13 Lab session.
Input and Output How things get into and out of the CPU.
ECE 265 – LECTURE 17 Simulator Project 8/7/ ECE265.
MIPS Instruction Set Advantages
Lecture 7: MIPS Instruction Set Today’s topic –Procedure call/return –Large constants Reminders –Homework #2 posted, due 9/17/
MIPS I/O and Interrupt. SPIM I/O and MIPS Interrupts The materials of this lecture can be found in A7-A8 (3 rd Edition) and B7-B8 (4 th Edition).
COMP201 Computer Systems Exceptions and Interrupts.
Input and Output Computer Organization and Assembly Language: Module 9.
A Few Words From Dilbert
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
MCU: Interrupts and Timers Ganesh Pitchiah. What’s an MCU ?
Writing an Embedded Controller. It usually consists of two parts – Initialization – A main loop More challenging than HW3 because HW3 is stateless, the.
HW #1 Problems & Industrial Strength Assembly CSCI 136.
MIPS I/O and Interrupt. .data val1:.float 0.6 val2:.float 0.8 msg_done:.asciiz "done\n".text.globl main main: li.s $f0, mfc1 $a0, $f0 jal calsqrt.
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
Timer Timer is a device, which counts the input at regular interval (δT) using clock pulses at its input. The counts increment on each pulse and store.
CSC 110 Using Python [Reading: chapter 1] CSC 110 B 1.
Subroutines, parameters and the stack Bryan Duggan.
Timers and Interrupts Anurag Dwivedi. Let Us Revise.
MIPS I/O and Interrupt.
Lecture 161 Lets examine a SPIM program in detail. io.asm This program is a simple routine which demonstrates input/output using assembly code. SPIM.
HW4. A TV controller Let’s use this lecture to start to develop a simple TV controller together.
EE 3755 Datapath Presented by Dr. Alexander Skavantzos.
Addressing Modes. Register Addressing Immediate Addressing Base Addressing Indexed Addressing PC-Relative Addressing.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
Networked Embedded Systems Pengyu Zhang & Sachin Katti EE107 Spring 2016 Lecture 4 Timers and Interrupts.
Programming in Arduino Materials:Arduino Board Casperelectronics Pre Pres. Notes Photos from workshop?
:Blink Blink: Er. Sahil Khanna
Microprocessors A practical approach..
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
MIPS Assembly Language Programming
MIPS Instruction Set Advantages
Writing an Embedded Controller
MIPS I/O and Interrupt.
Lab Find Live CMPUT 229.
MIPS I/O and Interrupt.
MIPS I/O and Interrupt.
MIPS Procedures.
MIPS Functions.
While Loops and If-Else Structures
Instruction encoding The ISA defines Format = Encoding
MIPS coding.
Review.
MIPS interrupt continued
While Loops and If-Else Structures
While Loops and If-Else Structures
MIPS function continued
MIPS Functions.
While Loops and If-Else Structures
MIPS I/O and Interrupt.
While Loops and If-Else Structures
Writing an Embedded Controller
While Loops and If-Else Structures
ECE 352 Digital System Fundamentals
While Loops And If-Else Structures
HW4.
MIPS Functions.
Presentation transcript:

Writing an Embedded Controller

It usually consists of two parts – Initialization – A main loop More challenging than HW3 because HW3 is stateless, the microcontroller has states. Experience: – The main loop usually has to deal with many things. It is important NOT to stay in any job for too long. You should process an event and almost immediately return to the main loop.

A Simple Program Write a program which – Prints out “everything is fine” every 3 seconds – Print out the ASCII of any key you have pressed immediately. Note: – Cannot sleep for 3 seconds and then print out the sentence – Must break away from the wait periodically to look for input (not using interrupt here)

.data msg_tvworking:.asciiz "everything is fine\n".text.globl main main: li $s0, 300 mainloop: # 1. get external input, and process it lui $t0, 0xFFFF lw $t1, 0($t0) andi $t1, 1 beq $t1, $0, mainloopnext1 # call the process_input function here lw $a0, 4($t0) li $v0, 1 syscall mainloopnext1: # 2. delay for 10ms jal delay_10ms # 3. print status addi $s0, $s0, -1 bne $s0, $0, mainloopnext4 li $s0, 300 la $a0, msg_tvworking li $v0, 4 syscall mainloopnext4: j mainloop li $v0,10 # exit syscall delay_10ms: li $t0, 3000 delay_10ms_loop: addi $t0, $t0, -1 bne $t0, $0, delay_10ms_loop jr $ra

HW4

A TV controller Let’s use this lecture to start to develop a simple TV controller together.

TV controller It accepts simple commands like vol+/-, channel +/-, channel digit input (0-99), sleep timer, and power on/off. When there is no input, roughly every 3 seconds, print out the current state of the TV, in the format of – Current second, Power On (of Off), Channel (current channel watching), volume (current volume), Sleep timer remaining. – For example, “At 100 second, Power On, Channel 10, Volume 30, sleep timer 120 sec remaining.” – If power is off, only output “At 100 sec, Power off.”

TV controller I didn’t find a timer facility in SPIM, so the time is approximated using delay loops.

Specifications Initialization. When the code started to run, the initial state is – Power on – Channel 0 (0-99) – Volume 50 (0-99) – Sleep timer off

Specifications Power key (should be ‘p’ on the key board) – When power key is pressed, if the power is currently off, turn on the TV immediately by printing “Power On!” – When power key is pressed, if the power is currently on, turn on the TV immediately by printing “Power Off!”

Specification Channel +/-. Should use ‘u’ as + and ‘d’ as -. Once pressed, change the current watching channel accordingly (but not out of range of 0- 99), and print out, for example, “Channel 30.” Allows wraparound.

Specifications Vol +/-. Should use ‘l’ as + and ‘k’ as -. Once pressed, change the current volume accordingly (but not out of range of 0-99), and print out, for example, “Volume 30.” Do not allow wraparound.

Specification Digit input. Use 0-9 key on key board. Used to change channels. – Once a digit key is pressed, print out the intended channel immediately. For example, `1’ is pressed, print out “1-” immediately. The controller should be expecting another digit input for another 2 seconds. If any other key is pressed during these two seconds, abort the digit input. For example, if `1’ is pressed at 1000 second and `channel +’ is pressed at 1001 second, the controller should perform the channel + function and “forget” about the digit input. If no other key is pressed during the two seconds, the controller switches to channel 1. If another digit key is pressed within the two seconds, for example, `2’ is pressed, the controller switches to channel 12 immediately.

Specifications Sleep timer. Should use ‘s’ key on the keyboard. – When hitting the sleep timer key, at the first time, do not change the status of the sleep timer and just show the current status. If the sleep timer key is pressed again within 3 seconds, then starts to modify the status of the sleep timer. That is, if the sleep timer is off, set the sleep timer to be 5 sec. If the sleep timer is on, increment the sleep timer by 5 sec. If the sleep timer exceeds 200 sec after the increment, set the sleep timer to be off. If the sleep timer is on, it decrements by 1 every second. Once it becomes 0, turn the TV off immediately and print out “Power off due to sleep timer!”

View history The “View history” key. – When pressed, print out the most watched 5 channels in a descending order. The channel is ordered according to the total amount of seconds this channel is watched since the TV is turned on. The time must be stored as single precision floating number.

Extra credits -- “Go-back” key The “Go-back” key (the `b’ key on the keyboard). When pressed, the TV should automatically switch back to current channel after 10 seconds. That is, if you pressed the “Go-back” key when watching channel 10 at time 1000 sec, at time 1010 sec, the TV should automatically go back to channel 10, regardless of what channel you are in.

Extra credit – Keyboard input with Interrupt Use the interrupt to implement the keyboard input function. Basically, you may use the interrupt to capture the input key value and write it to a register only for this purpose. In this assignment, let’s reserve $s7 for this. $s7 should be initialized with some impossible value such as You main loop should be constantly checking $s7, and if it is storing some value that is within 0-255, it means that the interrupt has written a value to it. The main loop should then reset it to be the impossible value.

Structure of the main loop Check for new key board input and process the input. If power is on, check if sleep timer hits 0. Loop for 0.01 second. Print out the status if 3 seconds elapsed since last status print. Jump to the beginning of the loop.