EE 319K Introduction to Embedded Systems

Slides:



Advertisements
Similar presentations
Matlab Intro Simple introduction to some basic Matlab syntax. Declaration of a variable [ ] Matrices or vectors Some special (useful) syntax. Control statements.
Advertisements

13-1 Bard, Gerstlauer, Valvano, Erez, Telang, Yerraballi EE 319K Introduction to Embedded Systems Lecture 13: 2-D Arrays, Bitmaps, Sprites, Structs, Lab.
Lab. 2 – More details – Tasks 4 to 6 1. What concepts are you expected to understand after the Lab. 2 is finished? 2. How do you demonstrate that you have.
CSC Timers Since this is a microcontroller it mainly finds itself in embedded devices Quite often embedded devices need to synchronize events The.
CSS 372 Lecture 1 Course Overview: CSS 372 Web page Syllabus Lab Ettiquette Lab Report Format Review of CSS 371: Simple Computer Architecture Traps Interrupts.
Some thoughts: If it is too good to be true, it isn’t. Success is temporary. It is hard work to make it simple. Knowing you did it right is enough reward.
8-Bit Timer/Counter 0 Counter/Timer 0 and 2 (TCNT0, TCNT2) are nearly identical. Differences: -TCNT0 can run off an external 32Khz clock (Tosc) or the.
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.
The 8051 Microcontroller and Embedded Systems
NS Training Hardware. System Controller Module.
EEE527 Embedded Systems Lecture 8: Practical Interrupts Ian McCrumRoom 5B18, Tel: voice mail on 6 th ring Web site:
1 Timing System Timing System Applications. 2 Timing System components Counting mechanisms Input capture mechanisms Output capture mechanisms.
Lab 2: Capturing and Displaying Digital Image
UNIT 8 Keypad Interface Contact Closure Counter Exceptions (Interrupts and Reset)
Higher Computing Computer structure. What we need to know! Detailed description of the purpose of the ALU and control unitDetailed description of the.
ARM Timers.
Revised: Aug 1, ECE 263 Embedded System Design Lessons 23, 24 - Exceptions - Resets and Interrupts.
Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN.
ECE 353 Introduction to Microprocessor Systems Discussion 11.
LAB 8: Program Design Pattern and Software Architecture
13-1 Bard, Gerstlauer, Valvano, Yerraballi EE 319K Introduction to Embedded Systems Lecture 13: 2-D Arrays, Bitmaps, Sprites, Structs, Lab 10.
Arch1 LCD Lab Eric Freudenthal. Topics Score Demo LCD Panel Geometry Utilities to draw to the display Drawing characters Buttons Nuisance: multiple versions.
GameBoy Advance Programming Sound. Sound Basics The Digital Process A / D Fs D / A Sound pressure fluctuations Analog voltage Digital voltage Sampling.
GameBoy Advance Programming Tiles. Atari 196?: As an engineering student at the University of Utah, Nolan Bushnell liked to sneak into the computer labs.
M. Smith University of Calgary.  Many people like to sing in the shower.  However, its rather boring as there is no accompaniment.  The McVASH device.
ECE 371 – Unit 9 Interrupts (continued). Example Set up Two Interrupt Request Inputs: –Port H[0] Set Interrupt Flag on “0” to “1” transition (rising edge)
ECS642U Embedded Systems Cyclic Execution and Polling William Marsh.
CS1372: HELPING TO PUT THE COMPUTING IN ECE CS1372 Some Basics.
YCbCr 4:2:2 with Embedded Syncs In / RGB Graphics Out Using an SDTV Generic Setup CSC Setup for HD YCbCr to RGB REG 0x04 = 0x81 // csc_ric1 0x05 = 0xD5.
FEM Power: 1. The TestBench version of the FEM requires A for proper operation. 2. The FEM can be powered from a 6U VME crate or from a lab.
Networked Embedded Systems Pengyu Zhang & Sachin Katti EE107 Spring 2016 Lecture 4 Timers and Interrupts.
Atmega328p Introduction for Digital and PWM Output Brion L Fuller II Robotics Club.
One more PIC18F252 example and revision for exam B222L Branislav Vuksanovic, UoP, ECE.
Problems in IO CS 1550 Recitation December 2 nd /4 th, 2002 The questions in this slide are from Andrew S. Tanenbaum's textbook page 376, 377.
Interrupt 마이크로 프로세서 (Micro Processor) 2015년 2학기 충북대학교 전자공학과 박 찬식
TM Freescale Confidential Proprietary Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names.
A walk through interrupts on the PPC 823
Peripherals – Keypad The Keypad provides a simple means of numerical data or control input. The keys can be attributed whatever data or control values.
LCD Interfacing using Atmega 32
80C51 Block Diagram ECE Overview.
Embedded Systems Programming Examples and Comparison
Microcontrollers & GPIO
CS4101 Introduction to Embedded Systems Lab 6: Low-Power Optimization
Binary Representation in Audio and Images
Timer and Interrupts.
4-Integrating Peripherals in Embedded Systems
4-Integrating Peripherals in Embedded Systems
Keyboard/Display Controller INTEL 8279
8-Bit Timer/Counter 0 Counter/Timer 0 and 2 (TCNT0, TCNT2) are nearly identical. Differences: -TCNT0 can run off an external 32Khz clock (Tosc) or the.
Microprocessor and Assembly Language
CENG2400 Revision Q1a A system has an ARM processor with a 32-bit General Purpose Input Output (GPIO) module. Two on/off switches are connected to bit-3.
Interrupts, Tasks and Timers
AT91RM9200 Boot strategies This training module describes the boot strategies on the AT91RM9200 including the internal Boot ROM and the U-Boot program.
Example 15 Interrupt-Driven Controller
전자의료시스템 및 실습 System Configuration/Interrupt
CSCI1600: Embedded and Real Time Software
Lab. 2 – More details – Later tasks
EE 319K Introduction to Embedded Systems
Microcontroller Labs Lab 1 – The LED Test Mode Dr. Gregg Chapman
This presentation will probably involve audience discussion, which will create action items. Use PowerPoint to keep track of these action items during.
CSCI1600: Embedded and Real Time Software
Welcome to: CSC225 Introduction to Computer Organization
Wireless Embedded Systems
Wireless Embedded Systems
CS4101 Introduction to Embedded Systems Lab 2: Basic IO and Timer
Basics of Embedded Systems IAX0230 Time Interfacing
Prof. Chung-Ta King Department of Computer Science
8051 Development System Details
WJEC GCSE Computer Science
Presentation transcript:

EE 319K Introduction to Embedded Systems 2-D Arrays, Bitmaps, Sprites, Game Engines

Agenda Agenda Software design 2-D array Bitmaps Wav Files Game Engines Lab 9

Software Design Modular programming Make it easier to understand Each screen is a complete story without scrolling Maximize the number of modules Minimize the interdependency Bandwidth of data passed from one to another Control coupling: actions in one cause effects in another Shared variables (very bad) Book Section 5.2

Software Design Design for test Manage resources Consider how it will be tested while designing Module has three files Header: What the module does Code: How it works Test: A main program used to test the module Manage resources LCD graphics Time (processor cycles) A fun game requires careful control of time Input/Output Switches, slide pot, DAC, LCD

2-D Array or Matrix What: 2 rows and 3 columns, 8 bits each Why: unsigned char M[2][3]; Why: Images Maps How: (C uses row major) C code to access M[i][j] = 5; Write this in assembly (R0=i, R1=j) i = row j = column n= # of columns Base+n*i+j Base+2*(n*i+j) Base+4*(n*i+j) Num of bytes/element

2-D Array or Matrix j i Base+2*(7*i+j) What: 6 rows and 7 columns Why: short Connect4[6][7]; Why: Images Maps How: (row major) Write C code to set array values to 0 i Base+2*(7*i+j)

2-D Array or Matrix j i Assuming C[6][7] // check the rows for(i=0;i<6;i++){ for(j=0;j<4;j++){ if((C[i][j]==1) &&(C[i][j+1]==1) &&(C[i][j+2]==1) &&(C[i][j+3]==1)){ Iwin(); } i 0 means free 1 means me -1 means you

Nokia 5110 Graphics Format Column 0 Row 0 Row 48 LCD is 48 rows, 84 columns, 1 bits/pixel Column 84

BMP File Format Sprites as objects moving across screen Sprites are monochrome W pixels wide by H pixels high

BMP File Format 16 wide, 10 high Placed at x=48, y=24 F F F F Nokia5110_PrintBMP(48,24,SmallEnemy10pointA,0); 16 wide, 10 high Placed at x=48, y=24 F F F F FFFFFFFFFF FFFFFFFFFFFF FFF FFFF FFF F FFFFFFFF F F F F F The raw data from BMP file to illustrate how the image is stored (0s replaced with spaces).

BMP File Format Example BMP file written as C constant Header (w x h) const unsigned char Enemy10Point1[] = { 0x42,0x4D,0xC6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x76,0x00,0x00,0x00,0x28,0x00, 0x00,0x00,0x10,0x00,0x00,0x00,0x0A,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x00,0x00, 0x00,0x00,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x80, 0x00,0x00,0x00,0x80,0x80,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x80, 0x00,0x00,0x80,0x80,0x80,0x00,0xC0,0xC0,0xC0,0x00,0x00,0x00,0xFF,0x00,0x00,0xFF, 0x00,0x00,0x00,0xFF,0xFF,0x00,0xFF,0x00,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF, 0x00,0x00,0xFF,0xFF,0xFF,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x0F,0x00,0x00,0x00,0x00,0xF0,0x00, 0x00,0x00,0xF0,0x00,0x00,0x0F,0x00,0x00, 0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xF0,0x00, 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00, 0x00,0xFF,0xF0,0xFF,0xFF,0x0F,0xFF,0x00, 0x00,0xF0,0xFF,0xFF,0xFF,0xFF,0x0F,0x00, 0x00,0xF0,0x0F,0x00,0x00,0xF0,0x0F,0x00, 0xFF }; Example BMP file written as C constant Header (w x h) Pixel data We use 4-bit BMP but all values above a threshold are deemed 1 for monochrome.

BMP Header Format

Timer 2A Periodic interrupt Resolution: bus period Precision: 32 bits Max period: 53 sec (80 MHz) 0) activate timer2 clock 1) disable timer2A 2) Precision to 32 bits 3) periodic mode 4) TAILR value 5) clock resolution 6) clear timeout flag 7) arm timeout 8) priority 4 9) enable in NVIC 10) enable timer2A

77 total INTERRUPT VECTORS Lab 7 Lab 8 Lab 9 Vector address Number IRQ ISR name in Startup.s NVIC Priority bits 0x00000038 14 -2 PendSV_Handler NVIC_SYS_PRI3_R 23 – 21 0x0000003C 15 -1 SysTick_Handler 31 – 29 0x00000040 16 GPIOPortA_Handler NVIC_PRI0_R 7 – 5 0x00000044 17 1 GPIOPortB_Handler 15 – 13 0x00000048 18 2 GPIOPortC_Handler 0x0000004C 19 3 GPIOPortD_Handler 0x00000050 20 4 GPIOPortE_Handler NVIC_PRI1_R 0x00000054 21 5 UART0_Handler 0x00000058 22 6 UART1_Handler 0x0000005C 23 7 SSI0_Handler 0x00000060 24 8 I2C0_Handler NVIC_PRI2_R 0x00000064 25 9 PWMFault_Handler 0x00000068 26 10 PWM0_Handler 0x0000006C 27 11 PWM1_Handler 0x00000070 28 12 PWM2_Handler NVIC_PRI3_R 0x00000074 29 13 Quadrature0_Handler 0x00000078 30 ADC0_Handler 0x0000007C 31 ADC1_Handler 0x00000080 32 ADC2_Handler NVIC_PRI4_R 0x00000084 33 ADC3_Handler 0x00000088 34 WDT_Handler 0x0000008C 35 Timer0A_Handler 0x00000090 36 Timer0B_Handler NVIC_PRI5_R 0x00000094 37 Timer1A_Handler 0x00000098 38 Timer1B_Handler 0x0000009C 39 Timer2A_Handler 0x000000A0 40 Timer2B_Handler NVIC_PRI6_R 0x000000A4 41 Comp0_Handler 0x000000A8 42 Comp1_Handler 0x000000AC 43 Comp2_Handler 0x000000B0 44 SysCtl_Handler NVIC_PRI7_R 0x000000B4 45 FlashCtl_Handler 0x000000B8 46 GPIOPortF_Handler 0x000000BC 47 GPIOPortG_Handler 0x000000C0 48 GPIOPortH_Handler NVIC_PRI8_R 0x000000C4 49 UART2_Handler 0x000000C8 50 SSI1_Handler 0x000000CC 51 Timer3A_Handler 0x000000D0 52 Timer3B_Handler NVIC_PRI9_R 0x000000D4 53 I2C1_Handler 0x000000D8 54 Quadrature1_Handler 0x000000DC 55 CAN0_Handler 0x000000E0 56 CAN1_Handler NVIC_PRI10_R 0x000000E4 57 CAN2_Handler 0x000000E8 58 Ethernet_Handler 0x000000EC 59 Hibernate_Handler 0x000000F0 60 USB0_Handler NVIC_PRI11_R 0x000000F4 61 PWM3_Handler 0x000000F8 62 uDMA_Handler 0x000000FC 63 uDMA_Error Lab 7 Lab 8 Lab 9 77 total INTERRUPT VECTORS

Timer 2A Periodic interrupt Max is 53 sec unsigned long TimerCount; void Timer2_Init(unsigned long period){ unsigned long volatile delay; SYSCTL_RCGCTIMER_R |= 0x04; // 0) activate timer2 delay = SYSCTL_RCGCTIMER_R; TimerCount = 0; TIMER2_CTL_R = 0x00000000; // 1) disable timer2A TIMER2_CFG_R = 0x00000000; // 2) 32-bit mode TIMER2_TAMR_R = 0x00000002; // 3) periodic mode TIMER2_TAILR_R = period-1; // 4) reload value TIMER2_TAPR_R = 0; // 5) clock resolution TIMER2_ICR_R = 0x00000001; // 6) clear timeout flag TIMER2_IMR_R = 0x00000001; // 7) arm timeout NVIC_PRI5_R = (NVIC_PRI5_R&0x00FFFFFF)|0x80000000; // 8) priority 4 NVIC_EN0_R = 1<<23; // 9) enable IRQ 23 in TIMER2_CTL_R = 0x00000001; // 10) enable timer2A } Output sound at 11.025 kHz

Timer 2A plays sounds TATORIS Ack Output sounds here Stuff // trigger is Timer2A Time-Out Interrupt // set periodically TATORIS set on rollover void Timer2A_Handler(void){ TIMER2_ICR_R = 0x00000001; // acknowledge TimerCount++; // run some background stuff here } void Timer2A_Stop(void){ TIMER2_CTL_R &= ~0x00000001; // disable void Timer2A_Start(void){ TIMER2_CTL_R |= 0x00000001; // enable TATORIS Ack Output sounds here Stuff Call to stop sound Call to start sound

Lab9 – Space Invaders, Pipe Dreams … There must be at least one button and one slide pot. There must be at least three images on the LCD display that move. There must be sounds appropriate for the game. The score should be displayed on the screen (but it could be displayed before or after the game action). At least two interrupt ISRs must used in an appropriate manner. The game must have a “time” aspect to it (For e.g., if you don’t move a sprite within a certain time it could be killed). Contrast with ConnectFour which is a taking “turns” game The game must be both simple to learn and fun to play.

Lab 9 – Grading The TA will certify your game and put you into one of two groups. Group A or B Lab 9 will be graded subjectively by other students During class we will setup two groups of stations each One team member demonstrates The other team member scores other 7 games in group Games are rank-ordered according to level of fun. Score is based on rank in group. 80 if 0th to 49th percentile 90 if 50th to 74th percentile 100 if 75th to 100th percentile