AT90S2313-Pulsewidth-Modulation
This application illustrates the working of AVR at AT90S2313 as 8-bit pulse width modulator .In this project the PIN OC1 toggles whenever there is a compare match occurs at OCR1A reg.
The program is as shown:
_SREG__ = 0x3f
__SP_H__ = 0x3e
__SP_L__ = 0x3d
__tmp_reg__ = 0
__zero_reg__ = 1
.global __do_copy_data
.global __do_clear_bss
.text
.global main
.type main, @function
main:
;--------PULSE WIDTH MODULATION USING AVR 90S2313---
;--------MAIN ROUTINE----------------------------
/* prologue: frame size=0 */
/*ldi r28,lo8(__stack - 0)
ldi r29,hi8(__stack - 0)
out __SP_H__,r29
out __SP_L__,r28
/* prologue end (size=4) */
ser r16 ; Setting the Register R16
out 0x11,r16 ; Setting the ‘DDRD’ Register as output mode
out 0X17,r16 ; Outputting high values through PORTB
clr r16 ; Clearing the R16
out 0x2C,r16 ; Loading zeros to TCNT1L & TCNT1H
out 0X2D,r16
out 0X2B,r16 ; Loading zeros to OCR1AH
ldi r16,0x0f
out 0X2A,r16 ; Loading 0F to OCR1AL
ldi r18,0x20
out 0X35,r18
ldi r22,0x81 ; Setting TCCR1A as 8-BIT PWM
out 0X2F,r22
ldi r19,0x01 ; Starting Timer1 as equal to clock
out 0X2E,r19
loop1:
;in r29,0X2C ; Loading TCNT1L value to R29
;out 0X12,r29 ; Loading the value through PORTD
rjmp loop1