some questions about timers in LPC1768

Hi, I have little problems with timers in LPC1768. I need to start timer2 because I use timer0 and timer1. When I want to configure and start timer2 all program doesn't start and I see nothing reaction - white display and no reaction. I have question: can I use more timers than 2? How many timers can I use ? And the second problem - I'd like to turn off one of the timers. How can I do it ? I understand that I must change pins on TCR register, but when I set bit 0 or 1 from documentation I turned off timer but I can't turn on again...I can turn off only once. I don't understand it.

LPC_TIM1->TCR |= 1 << 0; - start timer
LPC_TIM1->TCR |= 0 << 0; - turn off timer ? It doesn't work...

I also tried LPC_TIM1->TCR |= 1 << 1 but then timer didn't start again when I set
LPC_TIM1->TCR |= 1 << 0 again. I think that you understand what I mean. Thanks for help.

Parents
  • "LPC_TIM1->TCR |= 0 << 0; - turn off timer ? It doesn't work..."

    Time to read up on the operators in C.

    Do you really think that or:ing a zero will clear that bit?

    You do know the logic table for bitwise or?

    0 or 0 => 0
    0 or 1 => 1
    1 or 0 => 1
    1 or 1 => 1

    So when the bit in the register is 1 and you or with 0, you still end up with 1.

    Maybe, just maybe, bitwise or isn't a good route if you want to clear a bit...

Reply
  • "LPC_TIM1->TCR |= 0 << 0; - turn off timer ? It doesn't work..."

    Time to read up on the operators in C.

    Do you really think that or:ing a zero will clear that bit?

    You do know the logic table for bitwise or?

    0 or 0 => 0
    0 or 1 => 1
    1 or 0 => 1
    1 or 1 => 1

    So when the bit in the register is 1 and you or with 0, you still end up with 1.

    Maybe, just maybe, bitwise or isn't a good route if you want to clear a bit...

Children
More questions in this forum