Discussion 2 STATE MACHINES AND AVR ASSEMBLY CMPE 311 / FALL 2015 DR. MOHSENIN & MR. SMITH GTAS: RUTHVIK KUKKAPALLI, AMEY KULKARNI UTAS: JASON KLIMEK,

Slides:



Advertisements
Similar presentations
State Machines An approach to assembler coding. Intro State Machines are an integral part of software programming. State machines make code more efficient,
Advertisements

AVR ATMega32 Elementary Input / Output
Microcontroller Fundamentals
Chung-Ta King National Tsing Hua University
SHIFT REGISTERS: CONVERTING BETWEEN SERIAL AND PARALLEL DATA Mark Neil - Microprocessor Course 1 Serial versus Parallel Data Transfers.
MICRO-CONTROLLER: A microcontroller is the brain of the robot: These are: 1. Integrated Circuits (ICs) 2. Programmable.
Lab 3 General MIDI Explorer with Record/Playback
Programming Microcontrollers B. Furman 19MAR2011.
 | bit OR & bit AND ~ bit NOT ^ bit EXLUSIVE OR (XOR) > bit RIGHT SHIFT.
COMP3221: Microprocessors and Embedded Systems--Lecture 7 1 COMP3221: Microprocessors and Embedded Systems Lecture 7: Arithmetic and logic Instructions.
Mark Neil - Microprocessor Course 1 Decoding and Using a 4x4 Keyboard.
COMP3221: Microprocessors and Embedded Systems--Lecture 8 1 COMP3221: Microprocessors and Embedded Systems Lecture 8: Program Control Instructions
Programming the ATmega16
Embedded Systems 7763B Mt Druitt College of TAFE Electrical Engineering Lesson 2 LCD Display Interfacing.
Butterfly I/O Ports CS-212 Dick Steflik. I/O for our labs To get data into and out of our Butterfly its a little trickier than using printf and scanf.
COMP3221: Microprocessors and Embedded Systems
Railway Foundation Electronic, Electrical and Processor Engineering.
AVR Programming CS-212 Dick Steflik. ATmega328P I/O for our labs To get data into and out of our Arduino its a little trickier than using printf and.
Railway Foundation Electronic, Electrical and Processor Engineering.
An Embedded C Program 1 Mainly from textbook: Embedded C Programming and the Atmel AVR 2 nd Edition Barnett, Cox and O’Cull.
Robotics Research Laboratory Louisiana State University.
The 8051 Microcontroller and Embedded Systems
Assembly & Machine Languages
Bit Masking To access or affect only the bits we want, we need to construct a byte with bits set in the locations of interest – This byte is called a ‘bit.
AVR ATmega128 microcontroller
Timer/counter Chapter 12
CS-280 Dr. Mark L. Hornick 1 Calling subroutines in assembly And using the Stack.
I/O Ports CS-280 Dr. Mark L. Hornick 1. CS-280 Dr. Mark L. Hornick 2 Ports are channels from the CPU to external hardware and software Atmega32 has: 4.
A Simple Tour of the MSP430. Light LEDs in C LEDs can be connected in two standard ways. Active high circuit, the LED illuminates if the pin is driven.
Parallel Ports, Power Supply and the Clock Oscillator Material to be covered  Parallel I/O ports  Interfacing external switches and LEDs  Clock Oscillator.
SEED: A RISC Architecture Simulator Scriptable, Extensible, Emulator, and Debugger An Undergraduate Senior Research Project By: Ryan Moore Mentor: Dr.
AVR Programming: Digital I/O September 10, What is Digital I/O? Digital – A 1 or 0 Input – Data (a voltage) that the microcontroller is reading.
Timers and Interrupts Anurag Dwivedi. Let Us Revise.
Projects 8051.
ECE Lecture 1 1 L15 –I/O Part II Department of Electrical and Computer Engineering The Ohio State University ECE 2560.
Department of Electronic & Electrical Engineering Lecture 2 ● Introduction to IO ● Using a subroutine ● Driving a 7seg display.
Arduino Mega Arduino Mega 2560 Arduino Mega 2560.
BRANCHES SUBROUTINES AND MEMORY USAGE AVR Assembler M. Neil - Microprocessor Course 1.
Lab. 1 – GPIO Pin control Using information ENEL353 and ENCM369 text books combined with Blackfin DATA manual.
SHIFT REGISTERS: CONVERTING BETWEEN SERIAL AND PARALLEL DATA Mark Neil - Microprocessor Course 1 Serial versus Parallel Data Transfers.
Mark Neil - Microprocessor Course 1 Decoding and Using a 4x4 Keyboard.
Embedded Systems Lecture 4 January 20, 2016.
Introduction to AVR Name : 1) Abhishek Yadav ) Prakash Giri ) Kheni Niral ) Bhadresh Langadiya Branch.
80C51 Block Diagram 1. 80C51 Memory Memory The data width is 8 bits Registers are 8 bits Addresses are 8 bits – i.e. addresses for only 256.
Interfacing of Input/Output devices with AVR Microcontroller Enrolment No. : Name of the student: SOMAIYA ISHA.
One more PIC18F252 example and revision for exam B222L Branislav Vuksanovic, UoP, ECE.
“ INSTRUCTIONS SET OF AVR MICROCONTROLLER ” SIGMA INSTITUTE OF ENGINEERING Prepared By: SR.NO NAME OF STUDENT ENROLLMENT 1 Abhishek Lakhara
Embedded Systems Programming (What they do and when / how to use them)
AVR I/O Port Programming
Peripherals – Keypad The Keypad provides a simple means of numerical data or control input. The keys can be attributed whatever data or control values.
Introduction to Smart Systems
Embedded Systems Programming Examples and Comparison
(6. Sunu) (AVR Assembly Örnekleri)
COMP2121: Microprocessors and Interfacing
The Arduino Microcontroller: Atmel AVR Atmega 328
COMP2121: Microprocessors and Interfacing
ECET 330 Innovative Education--snaptutorial.com
I/O Ports in AVR Sepehr Naimi
Tim Sumner, Imperial College, Rm: 1009, x47552
Addressing Modes Register Direct, with 1 and 2 registers I/O Direct
Tim Sumner, Imperial College, Rm: 1009, x47552
I/O Ports in AVR Sepehr Naimi
Decoding and Using a 4x4 Keyboard
(Dr. Öğr. Üyesi Deniz Dal)
Lab. 1 – GPIO Pin control Using information ENEL353 and ENCM369 text books combined with Blackfin DATA manual.
COMP3221: Microprocessors and Embedded Systems
Some Assembly (Part 2) set.html.
Let’s use a PUSH-Button!
Decoding and Using a 4x4 Keyboard
Presentation transcript:

Discussion 2 STATE MACHINES AND AVR ASSEMBLY CMPE 311 / FALL 2015 DR. MOHSENIN & MR. SMITH GTAS: RUTHVIK KUKKAPALLI, AMEY KULKARNI UTAS: JASON KLIMEK, ALI AHMAD Slides by Ali Ahmad

Objectives Learn the basics of the design, structure and construction of state machines. Learn some basic AVR Assembly Commands: ◦LDI, RCALL, RJMP etc. Design and implement a simple state machine using AVR Assembly and the ATMEL IDE.

AVR Assembly Commands ◦AVR Assembly allows you to “map” registers – making variable names point to a specific register. Use the.DEF command for this: ◦.DEF PORTDEF = R22 ◦LDI (LoaD Immediate) Allows you to load a fixed value or constant into a register. ◦ LDI PORTDEF, 0b ◦MOV (MOVe) Allows you to copy a value from one register to another register. ◦.DEF NEWREG = R23 ◦ MOV NEWREG, PORTDEF ◦RCALL Calls a subroutine and can be returned to. ◦ STATE0: RCALL READINPUT ◦RJMP Jumps to a subroutine (typically can’t be returned to.) ◦ LOOPFOREVER: RJMP LOOPFOREVER

AVR Assembly Commands (Compare and Specific Jumps) ◦CP (ComPare) Sets a flag that allows you to do different kinds of jumps. ONLY WORKS WITH REGISTERS ◦ CP PORTDEF, NEWREG ◦BREQ Jumps if CP set Equal Flag. ◦ CP PORTDEF, NEWREG BREQ LOOPFOREVER ◦BRNE Jumps if CP set Not Equal Flag. ◦BRSH Jumps greater equal (unsigned) ◦BRLO Jumps if less (unsigned)

AVR Assembly Commands (Port/Register Conditionals) ◦SBRC Sets flag if register bit clear. ◦ SBRC PORTDEF, 7 RJMP LOOPFOREVER ◦SBRS Sets flag if register bit set ◦ SBRS PORTDEF, 7 RJMP LOOPFOREVER ◦SBIC Sets flag if port pin clear ◦SBIS Sets flag if port pin set ◦Many of the simple commands needed for this discussion can be found at this webpage. For a more thorough explanation see the website.this

Initializing I/O Ports Use the DDRx and PORTx registers to initialize ports as I/O. They are initialized with the OUT command. To initialize a pin as an input, make sure the DDR (Direction Register) for that pin number is set to 0 then activate the pull up resistor for that pin by writing a logic 1 to the PORT bit for that pin. ◦ LDI PORTDEF, 0b ;Assuming DDRB0 == 0 OUT PORTB, PORTDEF ;Activates pullup for Port B, pin 0 To initialize a pin as an output, write a logic 1 to the DDR register for that pin bit. ◦ LDI PORTDEF, 0b OUT DDRD, PORTDEF ;Port D, pin 0 is an output now Refer to section 13.2 in the AVR datasheet for more details.

State Machine Structure for Today The State Machine you are going to design will have 3 simple states: ◦State 1 – Rest State – pressing button turns on LED goes to State 2 ◦State 2 – LED On – pressing button beeps and goes to State 3 ◦State 3 – LED On (Beeped) – pressing button turns off LED and Resets to State 1 Let us know if you need any help!