Robotics Research Laboratory Louisiana State University.

Slides:



Advertisements
Similar presentations
Dr. Rabie A. Ramadan Al-Azhar University Lecture 3
Advertisements

Review: Interrupts & Timers
The 8051 Microcontroller Chapter 5 SERIAL PORT OPERATION.
I/O Unit.
ECE 447 Fall 2009 Lecture 9: TI MSP430 Interrupts & Low Power Modes.
Robotics Research Laboratory Louisiana State University.
ECE 372 – Microcontroller Design Parallel IO Ports - Interrupts
Mark Neil - Microprocessor Course 1 Timers and Interrupts.
Intro to AVR ATtiny2313 CS423 Dick Steflik. AVR ATtiny2313.
Interrupts What is an interrupt? What does an interrupt do to the “flow of control” Interrupts used to overlap computation & I/O – Examples would be console.
Communication Lab - Interrupts 1/13 Sequential Programming  Our C++ programs are sequential ( סדרתיים), they start at the first instruction and end at.
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.
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.
Robotics Research Laboratory Louisiana State University.
External & internal Interrupts. Interrupt Sources There are 21 different interrupts and each one has its own vector located in a predefined location at.
The 8051 Microcontroller and Embedded Systems
INTERRUPTS PROGRAMMING
Robotics Research Laboratory Louisiana State University.
V 0.91 Polled IO versus Interrupt Driven IO Polled Input/Output (IO) – processor continually checks IO device to see if it is ready for data transfer –Inefficient,
A Few Words From Dilbert
Unit 10.2 Timer Examples. Example – Music Generation Channel 6 – Set up as a timer Output to Generate Square Waves Channel 4 – Set up as a timer Output.
Lecture Set 9 MCS-51 Serial Port.
بسمه تعالي AVR Microcontrollers. The ATmega8 Basic Features -1.
Robotics Research Laboratory Louisiana State University.
I/O Interfacing A lot of handshaking is required between the CPU and most I/O devices. All I/O devices operate asynchronously with respect to the CPU.
1. Registers Used in Timer/Counter  TH0, TL0, TH1, TL1  TMOD (Timer mode register)  TCON (Timer control register) 2.
NS Training Hardware. Serial Controller - UART.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction Purpose  This training course provides an overview of the CPU architecture.
MICROCONTROLLER SYSTEMS Part 1. Figure 1.1Elements of a digital controller CPU Central Processing Unit Input Peripherals Output Peripherals ROM Read Only.
Atmel Atmega128 Overview ALU Particulars RISC Architecture 133, Mostly single cycle instructions 2 Address instructions (opcode, Rs, Rd, offset) 32x8 Register.
AVR Programming: Interrupts September 17, What are interrupts? An asynchronous signal indicating the need for an event to be handled A synchronous.
1 68HC11 Timer Chapter HC11 Timer Subsystem Several timing functions: Basic timing Basic timing Real time interrupts Real time interrupts Output.
ATtiny23131 A SEMINAR ON AVR MICROCONTROLLER ATtiny2313.
Interrupt. incoming Lab. Interrupt an asynchronous signal indicating the need for attention hardware interrupt/software interrupt call “interrupt service.
PPI-8255.
ECE 447 Fall 2009 Lecture 7: MSP430 Polling and Interrupts.
智慧電子應用設計導論(1/3) Arduino MEGA 2560
1 68HC11 Timer HC11 or HC12: Chapter HC11 Timer Subsystem  Several timing functions: Basic timing Basic timing Real time interrupts Real time.
Timers and Interrupts Mark Neil - Microprocessor Course.
CSCI1600: Embedded and Real Time Software Lecture 16: Advanced Programming with I/O Steven Reiss, Fall 2015.
EE/CS-352: Embedded Microcontroller Systems Part V The 8051 Assembly Language Interrupts.
kashanu.ac.ir Microprocessors Interrupts Lec note 8.
CS-280 Dr. Mark L. Hornick 1 Sequential Execution Normally, CPU sequentially executes instructions in a program Subroutine calls are synchronous to the.
The 8051 Microcontroller Chapter 6 INTERRUPTS. 2/29 Interrupt is the occurrence of a condition an event that causes a temporary suspension of a program.
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.
Transmitter Interrupts Review of Receiver Interrupts How to Handle Transmitter Interrupts? Critical Regions Text: Tanenbaum
Sensing Algorithm using IR Sensor and ADC Soong-sil University. Robotics 기 정 두 원.
1. PIC ADC  PIC18F877 has 8 analog input channels i.e. port A pins(RA0 to RA5) and port E pins(RE1 and RE2). These pins are used as Analog input pins.
Embedded Systems Programming
Microprocessor and Assembly Language
68HC11 Interrupts & Resets.
Table 2. Microcontroller pin description[5]
Interrupts In 8085 and 8086.
SERIAL PORT PROGRAMMING
BVM Engineering College Electrical Engineering Department : Microprocessor and Microcontroller Interfacing Interrupts of 8051 Prepared by:
Interrupt Source: under
Dr. Michael Nasief Lecture 2
The Arduino Microcontroller: Atmel AVR Atmega 328
8259 Chip The Intel 8259 is a family of Programmable Interrupt Controllers (PIC) designed and developed for use with the Intel 8085 and Intel 8086 microprocessors.
ATmega103 Timer0 and Interrupts
* * * * * * * 8051 Interrupts Programming.
CSCI1600: Embedded and Real Time Software
Interrupt.
8259 Programmable Interrupt Controller
Lecture 9: TI MSP430 Interrupts & Low Power Modes
Interrupt Source: under
8051 Micro Controller.
Interrupt Chapter 10.
PIC18 Interrupt Programming
CSCI1600: Embedded and Real Time Software
Presentation transcript:

Robotics Research Laboratory Louisiana State University

 UART – (Universal Asynchronous Receiver/Transmitter) ◦ Minimum required connection (RX,TX, and Ground)  RX – Receiver (yellow)  TX – Transmitter(green)  Ground - black ◦ Our programmer has 2 serial port  ttyACM0 : ISP programming port  ttyACM1 : UART serial port ◦ Wire connection  PE0  Yellow wire  PE1  Green wire  GND  Black wire ◦ Open Gtk-term  Set port : /dev/ttyACM1  Speed: for ttyACM for Bluetooth connection

 Config.h ◦ Set : #define CFG_USE_UART0 1  Hardware.h ◦ Set : #define UART0_BAUD_RATE57600  ADC_test.c ◦ Add : #include "UART.h” ◦ Create file pointer : FILE *u0;// for UART0 ◦ Open u0  if defined( __AVR_LIBC_VERSION__ )  u0 = fdevopen( UART0_PutCharStdio, UART0_GetCharStdio );  #else  u0 = fdevopen( UART0_PutCharStdio, UART0_GetCharStdio, 0 );  #endif ◦ Send values using fprintf(u0,”your message %d”, variable) ; /home/csc2700/csc2700/40-ADC-02

 Check the UART buffer first ◦ int UART0_IsCharAvailable()  Read a character from UART buffer ◦ int UART0_GetChar() int counter; char tmpChar; While(1){ if ( UART0_IsCharAvailable() ) { tmpChar = UART0_GetChar(); if ( tmpChar == ‘s'){ // start moving }else if ( tmpChar == ‘c'){ // clear counter }else if ( tmpChar == ‘r’){// report counter number }

 Some tasks need to be executed independently from main process  Some tasks need to be executed with specific timing ◦ ADC conversion, UART, PWM, etc  Some tasks need to be executed from arbitrary input signals ◦ external interrupts  Internal / External Interrupts

 Internal Interrupt ◦ Timer interrupt ◦ Counter interrupt ◦ ADC, SPM READY(Store Program Memory Ready),EE Ready  External Interrupt  INT0 = SCL [PD0]  INT1 = SDA [PD1]  INT2 = RXD1 [PD2]  INT3 = TXD1 [PD3]  INT4 = OC3B [PE4]  INT5 = OC3C [PE5]  INT6= T3[PE6]  INT7= ICP3 [PE7]  RESET= RESET [RESET]  SPI, UART, etc

Main program Interrupt service routine Interrupt occur Interrupt Register Bit check Interrupt Trigger check Save Main program PC at stack Jump to Triggered Interrupt Vector Execute Interrupt Service Routine Load PC from Stack then, return to Main program

1) Falling edge2) Rising edge 3) Low level High: + 4 V Low: 0.9 V

ISCn1ISCn0Trigger Signal 00The low level of INTn 01Reserved 10The falling edge of INTn 11The rising edge of INTn // Grab the rising edge. EICRB |= (( 1 << ISC71 )|( 1 << ISC70 )|( 1 << ISC61 )|( 1 << ISC60 )); // External interrupt control register B EIFR = (( 1 << INTF7 ) | ( 1 << INTF6 )); // External interrup flag register EIMSK |= (( 1 << INT7 ) | ( 1 << INT6 )); // External interrup mask register DDRE &= ~(( 1 << 6 ) | ( 1 << 7 )); // PE6 & PE7 set input PORTE |= (( 1 << 6 ) | ( 1 << 7 )); // pullup for input sei(); // set interrupt cli();// unset interrupt

int leftCounter = 0; int prevLeft = 0; int runFlag = 0; long cnt = ; main(1){ // Grab the rising edge. EICRB |= (( 1 << ISC71 )|( 1 << ISC70 )|( 1 << ISC61 )|( 1 << ISC60 )) // External interrupt control register B EIFR = (( 1 << INTF7 ) | ( 1 << INTF6 )); // External interrup flag register EIMSK |= (( 1 << INT7 ) | ( 1 << INT6 )); // External interrup mask register sei(); // set enable interrupt while(1){ if (leftCounter != prevLeft){ prevLeft = leftCounter; PIN(LED,1,SET_TOGGLE); } while (cnt-- > 0){ } cnt = ; } // interrupt service routine for int6 SIGNAL(SIG_INTERRUPT6){ leftCounter++; PIN(LED,0,SET_TOGGLE); } // SIG_INTERRUPT6

 Make a counter for the optical switches on wheels  Make a clear the counter when ‘c’ message is received from UART  Make a report the counter when ‘r’ message is received from UART  Make a robot move forward when ‘s’ message is received from UART until the counter value is 90

 Interrupts may need to set disable interrupt setting during their job processing ◦ for preventing endless chaining interrupts ◦ for some tasks need no interruption  ADC conversion  Transmitting and receiving procedure  SPI, UART, JTAG, etc  cli(): disable interrupt setting  sei(): enable interrupt setting

uint16_t a2d_10( uint8_t Channel ){ // Select the channel in a manner which leaves REFS0 and REFS1 un touched. ADMUX = ( ADMUX & (( 1 << REFS1 ) | ( 1 << REFS0 ))) | Channel; // Start the conversion ADCSR = ADCSR | ( 1 << ADSC ); // Wait for it to complete while ( ADCSR & ( 1 << ADSC )); return ADC; // ADC defined at avr/iom128.h ( special function register: SFR_IO16) } // a2d_10 int interrupt_counter=0; int a2d_value =0; main(1){ while(1){ cli();// clear interrupt enable set a2d_value = a2d_10(0);// read a2d value sei();// set enable interrupt fprintf(u0,” a2d= %d, counter = “, a2d_value,interrrupt_counter); delay(500); }

 It allows interrupt processes to read/write global variables even if main process is holding the variables ◦ Special Function Registers(SFR) are defined by volatile type ◦ If interrupt functions and the main function share a global variable, you should define the variable as volatile type - read/write failure

 Consideration for using optical switch on interrupt pins Black Bar IR detector Case 1 Output : 0 Case 2 Output : 1 Case 3 Output : 0 or 1