Edit: This post is updated with the solution code :)
Hello everyone :). I am trying to create a program that outputs a >50% duty cycle using timers. I am using 100 and 239.
.ORG 0x0 JMP MAIN .ORG 0x1C JMP TSR1 .ORG 0x1E JMP TSR2 MAIN: //Initializing the stack LDI R20,HIGH(RAMEND) OUT SPH,R20 LDI R20,LOW(RAMEND) OUT SPL,R20 //Initializing stack is done SBI DDRB,5 ;Setting PB5 as output LDI R20,239 ;Loading R20 with 239 OUT OCR0A,R20 ;Loading Timer0 with 239 LDI R21,100 ;Loading R21 with 100 OUT OCR0B,R21 ;Loading Timer1 with 100 LDI R20,(1<<WGM01) ;Setting timer mode to CTC OUT TCCR0A,R20 LDI R20,0x01 ;Start Timer0 OUT TCCR0B,R20 ; LDI R20,(1<<OCIE0A) | (1<<OCIE0B) ;Setting the ISR vector STS TIMSK0,R20 ;Enable Timer0 compare match interrupt SEI ;Enable interrupts HERE: JMP HERE TSR1: CBI PORTB,5 RETI TSR2: SBI PORTB,5 RETI
I am having trouble writing this program. Specially the main program. Can someone help me correct the main program? And please be kind enough to explain that :) I apologize if this question is dumb and does not suit the level of this forum :( I couldn't find similar assembly programs online.