my question is how do i do it with avr im using atmega 48 timer0 in toggle mode and using the mode 7 which has configurable top value option which means i can put the value of comparison in ocr as top value ive attached the code also please tell me what changes should i do for 50hz.........
.include "m48def.inc"
.org $0000
RJMP MAIN
.org $00E
RJMP TIMER_2
MAIN:
LDI R16, HIGH(RAMEND)
OUT SPH, R16
LDI R16, LOW(RAMEND)
OUT SPL, R16
LDI R16, 0
OUT PORTD, R16
OUT PORTB, R16
LDI R16, $FF
OUT DDRD, R16
OUT DDRB, R16
LDI ZL,low (Pos_cycle*2)
LDI ZH,high(Pos_cycle*2)
LDI R16, $02
STS TIMSK0, R16
LPM R16, Z+
OUT OCR0A, R16
LDI R16, $8F
OUT TCCR0A, R16
LDI R16, $09
OUT TCCR0B, R16
SEI
A:
RJMP A
TIMER_2:
LPM R16, Z+
OUT OCR0A, R16
CPI R16, 254
BRNE B
LDI ZL,low(Pos_cycle*2)
LDI ZH,high(Pos_cycle*2)
LPM R16, Z+
OUT OCR0A, R16
B:
RETI
Pos_cycle:
.db 00,03,06,10,12,15,21,24,27,30,33,36,42,45,48,51,54,57,60,63,69,72,75,78,81,84,87,93,96,99,102,105,108,114,117,120,123,126,129,132,135,141,144,147,150,153,156,159,160,163,169,172,175,178,181,184,187,193,196,199,202,205,208,211,214,217,220,223,226,229,232,235,238,241,245,248,251,254