Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[Question] LED blinking + brightness (using PWM + Timer)

Status
Not open for further replies.

wcgan

Member level 2
Joined
Nov 1, 2006
Messages
43
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Activity points
1,604
Hi all,

I have a project, below is the requirement:
-> Control LED brightness + blinking rate(OnTime and OFFtime).

I am able to control the LED brightness using PWM.

My idea is using Timer to set the blinking. How can I compile the PWM and TIMER together?

Microcontroller: Freescale (MC9S08JM16)

example:
I need to set the LED as below state:
LED blinking (OnTime:500ms, OffTime:500ms, Brightness:50%)?

Thanks for your help.

Regards,
wcgan
 

Sounds to me like you do not know well how to use timers.

Use interrupt on timer overflow. In this interrupt function set a int flag = 1.

In your main program code ... whatever it is just use if condition if in a loop... if flag is 1 then "do something" do something is done then flag is 0. next time loop checks the statement it will just will pass "do something" part and thats all you need.

To do the bilking part you need to turn PWM on or off in "do something" if flag is 1.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top