10 years ago.

32 bit Timer 0 match output

Hi all,

Its me again.. :)

I'd like to add an automatic LCD backlight control (say 30 secs) to my LPC11U35 project. So I'm planning to use the timer CT32B0's match output 0 to drive a BC817 via a current limiting resistor (2K2) which is connected to the backlight leds (pin 16 of the text lcd) cathode pin. And +5v for the anode.

Anyway, In theory it seems like it works..

However I have some difficulties about code writing that;

- Does CT32B0 used by tick or any timer command by mbed compiler? I am using tick timer command in my program.

- How can I load 20-30 sec timer value to CT32B0 and start it?

- Once it started (before it finished) , is it possible to restart it or it will continue with the current value?

- Is CT32B0's match output 0 pin suitable for that issue? If so how can I program it to "set low when match" status?

Thats all..

Thanks in advance for your helps..

With my best regards,

2 Answers

10 years ago.

The Ticker/Timer uses a different timer:

#define US_TICKER_TIMER          ((LPC_CTxxBx_Type *)LPC_CT32B1_BASE)

The other one is used for some of the PWM channels though.

For how to do it you should start with checking out the user manual for the LPC11u35. However what I wonder, why do you want to do it this way? If it is to try out directly using some hardware, okay. But this is precisely what for example TimeOut was created for, from a performance point of view there is no reason not to use that.

Accepted Answer
10 years ago.

Dear Erik,

Thanks first..

Do you say I can use both ticker and TimeOut functions without any conflict or jitter? ....

Ok.. Why I want to use another timer;

- I have already a ticker (and it must be exactly 1 second) in my code, so as my experiences if I do also something else with the default timer (as you now CT32B1 for M0) this tick will have some jitter! 1 second is my first priority then I have do something exactly every 1 second!

- So It's not a hardware function test..

- And in fact I was checking the user manual but dont understand which register should I set for all these..:(

I am an old 8051 man my friend.. And this processor seems very very complex to me!

Best regards, .

Ah yeah, that is in principle a reason to prefer another timer, so your very accurate 1 second stays very accurate. However:

Setting a pin high/low takes very little time. The overhead will cost more time, but still then I expect it to cost roughly 1us. So worst case a single one of your 1 second timer is of lets say really worst case, a few microseconds. And that will happen only if the backlight timeout is called very slightly before the 1 second ticker. This will also be only that one time, the next one will be correct again (so if one is delayed, and had an interval of 1.001 seconds, the next one will have one of 0.999 seconds, and after that all again 1.000).

posted by Erik - 19 Mar 2014