PWM.asm
1 | .include "tn2313def.inc"
| 2 |
| 3 | init:
| 4 | ldi r16, RAMEND ;stackinit (128byte RAM--> 8bit SP)
| 5 | out SPL, r16
| 6 | ldi r16, 0b11111111 ;portb als output
| 7 | out DDRB, r16
| 8 | ldi r16, 0 ;portb aus
| 9 | out PORTB, r16
| 10 | ldi r16, (1<<WGM00) | (1<<WGM01) | (1<<COM0A1) | (0<<COM0A0) | (1<<COM0B1) | (0<<COM0B0)
| 11 | ;fast PWM ;set OC0A at top, clear on compare match fuer A und B
| 12 | out TCCR0A, r16
| 13 | ldi r16, 156 ;zwei werte fuer OCR0x
| 14 | out OCR0A, r16
| 15 | ldi r16, 12
| 16 | out OCR0B, r16
| 17 | ldi r16, (1<<CS00) | (0<<CS01) | (0<<CS02) | (1<<WGM02) ;teiler 1, timer obergrenze OCR0A
| 18 | out TCCR0B, r16
| 19 | ldi r16, (1<<OCIE0A) | (1<<OCIE0B) ;interrupt ein (braucht man das ueberhaupt?)
| 20 | out TIMSK, r16
| 21 |
| 22 | main:
| 23 | ; einfach nixtun und den Timer arbeiten lassen ;)
| 24 | rjmp main
|
|