jamil916
Newbie level 4
- Joined
- Dec 20, 2012
- Messages
- 6
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,330
i am currently studying on 8051 PWM and need to generate a PWM period of 2 sec and 80% duty cycle with the use of timer interrupt.
However, when i run it it simply keep looping in the delay loop. Can anyone tell me what is wrong?
Here is the code i use:
;
However, when i run it it simply keep looping in the delay loop. Can anyone tell me what is wrong?
Here is the code i use:
Code ASM - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 #include <sfr51.inc> ORG 0000H ; CLR F0 ; JB F0, lowsignal ; highsignal: MOV A, #32 ; MOV R7, A ; SJMP delay ; ORG 000BH ; CLR F0 ; CLR P1.0 ; reti ; lowsignal: MOV A, #8 ; MOV R7, A ; SJMP delay ; ORG 000BH ; SETB F0 ; SETB P1.0 ; reti ORG 0030H ; delay: loop: fiftymsdelay: ; 50ms delay MOV TMOD, #01H ; timer 0, mode 1 MOV TH0, #3CH ; MOV TL0, #0B0H ; load 15,536 (3CB0H) into timer 0 SETB EA ; enable timer 0 interrupt SETB ET0 ; SETB TR0 ; start timer 0 DJNZ R7, loop ; loop 50ms delay 32 times for a 1.6s delay , 8 times for 0.4 s delay END
Last edited by a moderator: