; Prac 4 - Using the AVR PWM ;****************************************************** .include "8515def.inc" rjmp RESET ;Reset Handle reti ; We don't use INT0 ; ; Jump to INT1 ISR ;****************************************************** RESET: .def temp =r16 .def temp2 = r17 ldi temp,low(RAMEND) out SPL,temp ldi temp,high(RAMEND) out SPH,temp ;init Stack Pointer ; Initialise PORTB for input ; ; Initialise PORTD - INT1 must be set as input, OC1A to output ; ; Set the initial value for the timer to count to ; ; Select as 8-bit PWM ; ; Select timer to run at full clock speed ; ; Enable the INT1 interrupt ; ; Enable interrupt on falling edge of INT1 (the pushbuttons are active-low) ; ; Enable interrupts ; ; Sit back and wait for interrupts to happen mainloop: rjmp mainloop ; INT1 Service routine ; We don't use any other registers in the program, so don't have to save them INT1_ISR: ; Read in data from PORTB ; ; Output it to the PWM register ; ; Return from the interrupt ;