Joe Crop. ISR(TIMER1_COMPA_vect) { PORTD = syncON; //start the Horizontal sync pulse LineCount++ ;...
-
Upload
anabel-rose -
Category
Documents
-
view
231 -
download
1
Transcript of Joe Crop. ISR(TIMER1_COMPA_vect) { PORTD = syncON; //start the Horizontal sync pulse LineCount++ ;...
Joe Crop
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}
AVR-GCC
#include <avr/sleep.h>sleep_enable();sleep_CPU();
CodeVision Compiler
MCUCR = 0b00100000;#asm ("sleep");
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.
char screen[800];
0 1 2 3 4 5 6 78 9 10 11 12 13 14 15
792 793 794 795 796 797 798 799
.
.
//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;
Line 1:Line 2:
Line 100:
AVR-GCCIf((v1 & 0b10000000) != 0){
PORTD |= 0x40;}else{
PORTD &= 0xBF;asm("nop"::);
}asm("nop"::); asm("nop"::); asm("nop"::);
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;
What do you expect the assembly to be?
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.
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
My Version of Wii Fit