1 / 11

AVR Video Generation

Joe Crop. AVR Video Generation. NTSC Composite Video Signal. NTSC Composite Video Signal. The Video Circuit. V&H Sync. ISR(TIMER1_COMPA_vect) { PORTD = syncON; //start the Horizontal sync pulse LineCount++ ; //update the current scanline number

gibson
Télécharger la présentation

AVR Video Generation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Joe Crop AVR Video Generation

  2. NTSC Composite Video Signal

  3. NTSC Composite Video Signal

  4. The Video Circuit

  5. V&H Sync ISR(TIMER1_COMPA_vect) { PORTD = syncON; //start the Horizontal sync pulse LineCount++ ; //update the current scanline number if (LineCount==248) //begin inverted (Vertical) sync after line 247 { syncON = 0b00100000; syncOFF = 0; } if (LineCount==251) //back to regular sync after line 250 { syncON = 0; syncOFF = 0b00100000; } if (LineCount==263) //start new frame after line 262 { LineCount = 1; } _delay_us(2.65); //extra delay for 16MHz CPU PORTD = syncOFF; //end sync pulse }

  6. avr/sleep.h CodeVision Compiler MCUCR = 0b00100000; #asm ("sleep"); AVR-GCC #include <avr/sleep.h> sleep_enable(); sleep_CPU(); Other Functions //idle, power-down, ADC noise reduction, standby... set_sleep_mode(<mode>); sleep_mode(); // go to sleep with selected mode. sleep_disable(); // disable sleep mode.

  7. Pixel Manipulation char screen[800]; Line 1: Line 2: . . Line 100: //left-shift 3 would be individual lines // <<2 means line-double the pixels //The 0xfff8 truncates the odd line bit //ScreenTop=30, ScreenBot=230 i=(LineCount-ScreenTop)<<2 & 0xfff8;

  8. Predicting the Compiler CodeVision Compiler PORTD.6 = v1 & 0b10000000; PORTD.6 = v1 & 0b01000000; PORTD.6 = v1 & 0b00100000; PORTD.6 = v1 & 0b00010000; PORTD.6 = v1 & 0b00001000; PORTD.6 = v1 & 0b00000100; PORTD.6 = v1 & 0b00000010; PORTD.6 = v1 & 0b00000001; AVR-GCC If((v1 & 0b10000000) != 0) { PORTD |= 0x40; } else { PORTD &= 0xBF; asm("nop"::); } asm("nop"::); asm("nop"::); asm("nop"::); What do you expect the assembly to be?

  9. Predicting the Compiler • Unfortunately we can’t trust GCC to compile this bit-for-bit. • GCC adds random “bookkeeping” code that ruins the timing. • Proposed Solution: • Put video variables in registers • register uint8_t v1 asm(”r6"); • Write video generation code in assembly.

  10. References / Sources • Stanford University EE281 Lab 4: "TV Paint” • http://www.stanford.edu/class/ee281/handouts/lab4.pdf • Atmel Applications Journal: AVR video generator with an AVR Mega163 • http://www.atmel.com/dyn/resources/prod_documents/mega163_3_04.pdf • Cornell University EE476: "Video Generation with AVR Microntrollers” • http://instruct1.cit.cornell.edu/courses/ee476/video/index.html

  11. Demonstration My Version of Wii Fit

More Related