Discussion in "8051 Discussion Forum" started by    neil03    Aug 5, 2009.
Wed Aug 05 2009, 07:33 PM
#1
hi im working on a PWM signal output from a microcontroller using at89c2051.
The status of my project is that I successfully produce the desired PWM signal but, my problem is I cannot stop the process of stopping the PWM signal when I switch it to stop.
____________________________________________________________________
The algorithm of the program is simply like this

1. when switch 1 is pressed the microcontroller produce a PWM signal
2. when switch 2 is pressed the micrcontroller stop producing the signal or clearing the output pin of the MC.
____________________________________________________________________
Now as I have said above I successfully produce the desired PWM signal but when I switch it to stop. The PWM output pin remains to produce the PWM signal..Honestly this program is really working previously and I have used this program several times ago but now when I try to burn it on a new microcontroller it doesnt respond to its previous state.. I also try to change different at89c2051, 3 mc to be exact, but still im getting the same problem..
Im thinking that the maybe the programmer have a defect or something, but im not so sure and I dont want to take the risk of buying a new programmer cause it costs alot.

Can anybody help me to find what is the problem causing this and please teach me to resolve it..I have attach the program and the schematic of my project. please help me people thank you so much.
 switch1   EQU P1.2     ; switch for PWM
 switch2   EQU P1.3		; switch for stop PWM signal
 PWMPIN    EQU P3.4      ; PWM output pin 

ORG 00H
SJMP Main

org 0BH ;Vector address for Timer0
AJMP TIMER_0_INTERRUPT ;jump to ISR routine

;Main code
Main:
JB  P1.2, PWM_INI ; go to PWM setting 1
sjmp Main

PWM_INI:         ;initiate PWM
acall PWM_SETUP 
here:
JB   P1.3, STOP;
SJMP here ;

STOP:
clr PWMPIN
sjmp Main;


PWM_SETUP:
        MOV TMOD,#00H           ; Timer0 in Mode 0
        MOV R7, #240            ; Set pulse width control
        ; The value loaded in R7 is value X as
        ; discussed above.
        SETB EA         ; Enable Interrupts
        SETB ET0                ; Enable Timer 0 Interrupt
        SETB TR0                ; Start Timer
        RET

TIMER_0_INTERRUPT:
        JB F0, HIGH_DONE        ; If F0 flag is set then we just finished
                                ; the high section of the
LOW_DONE:                       ; cycle so Jump to HIGH_DONE
        SETB F0                 ; Make F0=1 to indicate start of high section
        SETB PWMPIN             ; Make PWM output pin High
        MOV A, #0FFH            ; Move FFH (255) to A
        CLR C                   ; Clear C (the carry bit) so it does
                                 ; not affect the subtraction
        SUBB A, R7              ; Subtract R7 from A. A = 255 - R7.
        MOV TH0, A              ; so the value loaded into TH0 + R7 = 255
		CLR TF0                 ; Clear the Timer 0 interrupt flag
        RETI                    ; Return from Interrupt to where
                                        ; the program came from
HIGH_DONE:
        CLR F0                  ; Make F0=0 to indicate start of low section
        CLR PWMPIN              ; Make PWM output pin low
        MOV TH0, R7             ; Load high byte of timer with R7
                                ; (pulse width control value)
        CLR TF0                 ; Clear the Timer 0 interrupt flag
        RETI                    ; Return from Interrupt to where
                                ; the program came from




END






[ Edited Wed Aug 05 2009, 07:35 PM ]
Wed Aug 05 2009, 07:51 PM
#2
well schematic is not so big to have a problem in it.

You can load a simple LED blink program to see if your controller is fine or not.

I think problem seems to be in program for making it non stop PWM. the reason is.. PWM works with timer so along with clearing of PWM pin, you should also clear TR0, and TF0 so that timer stops and interrupt flags can be cleared. and to start PWM again, you have the init function.

[Topic moved to 8051 Discussion forum]
Thu Aug 06 2009, 02:07 AM
#3
You'll also have to make sure the SW1 switch is off else the pwm generation will start again.
better implement sth like this....
Main:
JNB  P1.2, Main;check if START is pressed
JNB P1.3,PWM_INI ; go to PWM setting 1 if STOP not pressed
sjmp Main

Get Social

Information

Powered by e107 Forum System

Conversation

Mon May 08 2017, 12:45 PM
ivan muvunyi
please can you send me wiring diagram for automatic control of 3 phase induction motor for production of maize flour
Wed May 03 2017, 08:39 PM
imran qureshi
hello friend
Sun Apr 30 2017, 05:49 AM
Lijin G Varghese
Can u send me the circuit diagram for Program to interface GSM Module with 8051 microcontroller (AT89C51) using PC and LCD
Fri Apr 28 2017, 03:47 PM
SANDEEP T S
I need pcb wizard 3.5 version kindly send valid link of yours
ExperimenterUK
Mon Apr 17 2017, 11:56 PM
Sorry..We had a problem with registration.Confirmation emails were not sent.Please re-register
Thu Apr 13 2017, 07:29 PM
Piyush Aughad
I want circuit & program for radar detection using Microcontroller 8051
Tue Apr 11 2017, 03:27 AM
Shabbir Ahmed
Hi Ajay ....hope you and your family all will be fine are you working on andriod aplications if yes then plz reply me
Sun Apr 09 2017, 06:33 PM
ATHULYA NAIR
Dear Sir, I need to know what are the complexity for programming in 8051 Microcontroller for three phase inverter?
Sun Apr 09 2017, 06:32 PM
ATHULYA NAIR
Dear Sir,
Sun Apr 09 2017, 04:43 AM
Rohit chandra joshi
Sir I need ur help urgently.i am trying to make pc controlled led scrolling display using 8051.when i am trying to generate hex file of the code that is given by pratik suthar.it gives the error Target not created Limit:0800h I am using keil uvision4 software. Even i have tried to burn the given hex file that is atteched with the code but my led are not glowing. Pls help me sir .i struck in this problem from last month and till now i am not able to short out the problem. Pls suggest me to solve the problem.mail me at [email protected] Thanks

Downloads

Comments

lubnakhan
Sat May 20 2017, 10:23 AM
Utsavi
Wed May 17 2017, 10:35 AM
Samimash
Tue May 16 2017, 01:15 PM
gangusa
Mon May 15 2017, 04:34 AM
raghuzala
Sun May 14 2017, 02:32 PM
Prakashlimbachiya
Sat May 13 2017, 07:34 AM
east
Fri May 12 2017, 08:16 AM
ajay24
Fri May 12 2017, 08:09 AM

Online

Guests: 55, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 37827
Newest member: lubnakhan
Forum Activity
ajay_bhargav Avatar
Posted By ajay_bhargav
Fri May 19 2017, 10:17 AM
I think you are asking in the wrong forum. We do n...
ajay_bhargav Avatar
Posted By ajay_bhargav
Fri May 19 2017, 10:16 AM
You should start with something, We will help you ...
ajay_bhargav Avatar
Posted By ajay_bhargav
Fri May 19 2017, 07:01 AM
To me it looks like your development environment i...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu May 18 2017, 11:28 PM
Linux can be a minefield of make files, scripts an...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu May 18 2017, 11:18 PM
Can you provide me a demo of XAG-49 counter so tha...
Utsavi Avatar
Posted By Utsavi
Thu May 18 2017, 05:57 AM
HelloThanks for reply.No the input pin is not faul...
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed May 17 2017, 07:38 PM
Just from reading the data sheet you seem to doing...
Utsavi Avatar
Posted By Utsavi
Wed May 17 2017, 11:01 AM
HelloI am working with PXAG49KBA. In my project I ...
Samimash Avatar
Posted By Samimash
Wed May 17 2017, 04:37 AM
thank you for your reply friend 'cc1' is a file ac...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue May 16 2017, 05:05 PM
I'm sure this is a compiler / Linux problem.In Lin...