Mercurial > nyan
changeset 17:184193daf9aa tiny10
tiny10 code
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Fri, 30 Dec 2016 23:16:58 +0100 |
| parents | 393915e97bb1 |
| children | 1d1ca74ade50 |
| files | main/Makefile main/main.c |
| diffstat | 2 files changed, 10 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/main/Makefile Thu Dec 01 15:51:42 2016 +0100 +++ b/main/Makefile Fri Dec 30 23:16:58 2016 +0100 @@ -1,11 +1,11 @@ -DEVICE = attiny85 +DEVICE = attiny10 CLOCK = 1000000 -PROGRAMMER = -c usbasp +PROGRAMMER = -c usbasp-clone OBJECTS = main.o # for ATTiny85 # see http://www.engbedded.com/fusecalc/ -FUSES = -U lfuse:w:0x62:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m +#FUSES = -U lfuse:w:0x62:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m # Tune the lines below only if you know what you are doing: AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE)
--- a/main/main.c Thu Dec 01 15:51:42 2016 +0100 +++ b/main/main.c Fri Dec 30 23:16:58 2016 +0100 @@ -37,12 +37,14 @@ } note; byte raw; } note; + uint32_t count; while (length --> 0) { note.raw = pgm_read_byte_near(notes++); if (note.note.octave) { - TCCR0B = 2; - OCR0A = pgm_read_byte_near(FREQ + note.note.tone) >> (note.note.octave - 1); + TCCR0B = 1<<WGM02 | 0b001; // /1 prescaler + count = (pgm_read_byte_near(FREQ + note.note.tone) << 4) >> (note.note.octave - 1); + OCR0A = count; } if (note.note.length) { _delay_ms(220); @@ -53,14 +55,13 @@ TCCR0B = 0; _delay_ms(15); } - PORTB ^= 1<<3 | 1<<4; + PORTB ^= 1<<1; } } int main() { - DDRB = 1<<0 | 1<<3 | 1<<4; - TCCR0A |= 1<<COM0A0 | 1<<WGM01; - PORTB ^= 1<<4; + DDRB = 1<<0 | 1<<1; + TCCR0A = 1<<COM0A0; play(INTRO_NOTES, 26); while(1) { play(MELODY_NOTES, 216);
