]> www.fi.muni.cz Git - bike-lights.git/commitdiff
PWM experiments
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Fri, 8 Jun 2012 16:19:58 +0000 (18:19 +0200)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Fri, 8 Jun 2012 16:19:58 +0000 (18:19 +0200)
lights.c

index 18eef189e6ca9d3134613a906deedfcf5b661aac..0bedc53e2e059f070a82bdcee6e00381adeca255 100644 (file)
--- a/lights.c
+++ b/lights.c
@@ -1,8 +1,26 @@
 #include <avr/io.h>
 #include <avr/io.h>
+#include <avr/eeprom.h>
 #include <util/delay.h>
 
 #include <util/delay.h>
 
+char dbg[5] __attribute__((section(".eeprom")));
+
 int main(void)
 {
 int main(void)
 {
+       TCCR1C = _BV(COM1D0) | _BV(COM1D1) | _BV(PWM1D);
+       TCCR1A = _BV(PWM1A) | _BV(PWM1B);
+       TCCR1B = 0x80 | _BV(CS13) | _BV(CS12);
+       OCR1C = 0xFF;
+       OCR1D = 0x20;
+       TCNT1 = 3;
+       DDRB |= _BV( PB5 );
+       PORTB &= ~_BV( PB5 );
+
+       _delay_ms(1000);
+       eeprom_write_byte(&dbg[0], TCNT1);
+       eeprom_write_byte(&dbg[1], OCR1C);
+       eeprom_write_byte(&dbg[2], OCR1D);
+       eeprom_write_byte(&dbg[3], TIFR);
+       eeprom_write_byte(&dbg[4], TCCR1B);
     DDRA |= _BV( PA0 );
     while( 1 ) { 
         PORTA |=  _BV( PA0 );
     DDRA |= _BV( PA0 );
     while( 1 ) { 
         PORTA |=  _BV( PA0 );