EE 319K�Introduction to Embedded Systems
Lecture 13: �Lab 10 Requirements, Schedule, Game engine, Sound
Bard, Tiwari, Cuevas, Holt, Gerstlauer, Valvano, Erez, Telang, Yerraballi
http://youtu.be/QxDQUUDStOw
13-1
Agenda
Bard, Tiwari, Cuevas, Holt, Gerstlauer, Valvano, Erez, Telang, Yerraballi
https://www.youtube.com/watch?v=KgrlOPFZtlo
13-2
Lab10 – Schedule
Bard, Tiwari, Cuevas, Holt, Gerstlauer, Valvano, Erez, Telang, Yerraballi
13-3
Lab10 – Requirements
Bard, Tiwari, Cuevas, Holt, Gerstlauer, Valvano, Erez, Telang, Yerraballi
13-4
Lab10 – Standard Connections
Bard, Tiwari, Cuevas, Holt, Gerstlauer, Valvano, Erez, Telang, Yerraballi
These connections are optional
TAs can run your code
Avoid PB7 PB6 because
-PB7 connected to PD1
-PB6 connected to PD0
13-5
Lab 10 – Extra Features
Here are some extra features you may consider implementing if you want your game to stand out. Doing these features is also a good exam preparation strategy:
Spring 2022 has no extra credit in Lab 10
13-6
EE319H Software Design
Bard, Tiwari, Cuevas, Holt, Gerstlauer, Valvano, Erez, Telang, Yerraballi
Move code into same module
13-7
Game Engine – Call graph
Bard, Tiwari, Cuevas, Holt, Gerstlauer, Valvano, Erez, Telang, Yerraballi
13-8
Game Engine – Data Flow
Bard, Tiwari, Cuevas, Holt, Gerstlauer, Valvano, Erez, Telang, Yerraballi
6 bits
6-bit DAC
13-9
Software Testing
Bard, Tiwari, Cuevas, Holt, Gerstlauer, Valvano, Erez, Telang, Yerraballi
It is SO SAD to see students in office hours, asking “Why does my game not work?”
13-10
Resource Constrained
Bard, Tiwari, Cuevas, Holt, Gerstlauer, Valvano, Erez, Telang, Yerraballi
50% of the time is spent sending images to the LCD
13-11
Game Engine – Flowchart
Bard, Cuevas, Holt, Gerstlauer, Valvano, Erez, Telang, Yerraballi
Could use GPIO edge-triggered interrupts
13-12
Three threads
void SysTick_Handler(void){ // 30 Hz, every 33ms
// read switches, what do the switches mean?
// read ADC, what does the slide pot mean?
// run the game engine, move sprites, collisions
// if needed, start sound (arm TIMER2A, set parameters)
Semaphore = 1; // things have changed
} // time to execute this ISR is much less than 33ms
int main(void){
DisableInterrupts();
// initializations
EnableInterrupts();
while(1){
if(Semaphore){
// LCD output
Semaphore = 0;
}
}
}
void Timer2A_Handler(void){// 11kHz
// acknowledge interrupt
// if playing sound, one DAC out
}
13-13
Need more timers?
13-14
Timer 2A Periodic interrupt
Bard, Tiwari, Cuevas, Holt, Gerstlauer, Valvano, Erez, Telang, Yerraballi
0) activate timer2 clock
1) disable timer2A
2) Precision to 32 bits
3) periodic mode
4) TAILR value (analogous to RELOAD)
5) clock resolution
6) clear timeout flag
7) arm timeout
8) priority 4
9) enable in NVIC
10) enable timer2A
13-15
Timer 2A Periodic interrupt
void (*PeriodicTask)(void); // user function
void Timer2_Init(void(*task)(void), uint32_t period){
SYSCTL_RCGCTIMER_R |= 0x04; // 0) activate timer2
PeriodicTask = task; // user function
TIMER2_CTL_R = 0x00000000; // 1) disable timer2A
TIMER2_CFG_R = 0x00000000; // 2) 32-bit
TIMER2_TAMR_R = 0x00000002; // 3) periodic mode
TIMER2_TAILR_R = period-1; // 4) reload value
TIMER2_TAPR_R = 0; // 5) 12.5ns 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
// vector number 39, interrupt number 23
NVIC_EN0_R = 1<<23; // 9) enable IRQ 23 in
TIMER2_CTL_R = 0x00000001; // 10) enable timer2A
}
Starter sounds are 8-bit 11.025 kHz
Output one data to DAC at 11.025 kHz
Slowest period is 53 sec
13-16
Timer 2A plays sounds
// trigger is Timer2A Time-Out Interrupt
// set periodically TATORIS set on rollover
void Timer2A_Handler(void){
TIMER2_ICR_R = TIMER_ICR_TATOCINT;// ack
(*PeriodicTask)(); // execute user task
}
void Timer2A_Stop(void){
TIMER2_CTL_R &= ~0x00000001; // disable
}
void Timer2A_Start(void){
TIMER2_CTL_R |= 0x00000001; // enable
}
Ack
Stuff
Output one value to DAC to create sound
Call to stop sound
Call to start sound
TATORIS
Bard, Tiwari, Cuevas, Holt, Gerstlauer, Valvano, Erez, Telang, Yerraballi
13-17
Sound
Bard, Tiwari, Cuevas, Holt, Gerstlauer, Valvano, Erez, Telang, Yerraballi
http://users.ece.utexas.edu/~valvano/Volume1/downloads.htm
http://users.ece.utexas.edu/~valvano/Volume1/WC.m
http://users.ece.utexas.edu/~valvano/Volume1/WavPlay.zip
https://youtu.be/YHZj54ag83A
https://youtu.be/ThSmcr06Pnc
13-18