From 70e877008faf5e7308d6ca42ec7e8695bdf22279 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Sat, 24 Dec 2011 18:30:04 +0100 Subject: [PATCH] Some comments added. --- firmware/main.c | 15 +++++++-------- firmware/main.h | 5 +++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/firmware/main.c b/firmware/main.c index 8ac558a..42f4231 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -33,20 +33,20 @@ void init() DDRB = 0b11111111; // PB0-PB7: LED 1-8 (Kathode) PORTB = 0b11111111; // HIGH - DDRD = 0b01111000; // PD6: LED 9 (Kathode); PD5-PD3: A-C (Anoden) + DDRD = 0b01111000; // PD6: LED 9 (Kathode); PD5-PD3: A-C (Anode) PORTD = 0b01000000; - // Setup Timer-Interrupt "TIMER1" + // Setup Timer-Interrupt "TIMER1" compare match interrupt TIMSK |= (1 << OCIE1A); - // Refreshrate is 100Hz - // Set the compare value + // Refreshrate is 100Hz of the whole LEDCube. + // The ISR comes up at 300Hz. + // Set the compare value to // 625d = 0x271 = 0b00000010, 0b01110001 OCR1AH = 0b00000010; OCR1AL = 0b01110001; - // anpassen auf reihenweise ausgabe - // prescale is 64 (0x011) ----> CS12=0, CS11=1, CS10=1 + // Set prescale to 64 and clear the counter on compare match. TCCR1B |= (1 << CS11) | (1 << CS10) | (1 << WGM12); sei(); // Enable interrupts global @@ -56,8 +56,7 @@ void init() ISR (TIMER1_COMPA_vect) { - //delay--; // decrease the delay counter - if ( !(--delay) ) // check if we are done with waiting + if ( !(--delay) ) // decrease the counter and check if we are done with waiting { if (frmnum == MAX_EEPROM_FRAMES) { diff --git a/firmware/main.h b/firmware/main.h index 91c3d59..4556b11 100644 --- a/firmware/main.h +++ b/firmware/main.h @@ -20,6 +20,11 @@ #include // Cube-Data +// bit 0 - 8 = level 1 +// bit 9 - 17 = level 2 +// bit 18 - 26 = level 3 +// bit 27 - 31 = The delay in ISR calls multiplied with 8 until +// the next frame will be shown (load from the EEPROM) uint32_t frame; uint8_t level; // current layer