This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Counter not resetting to 0

I have an LPC24 board and I'm struggling to get the counter to reset to 0.

        int countval;
        T1TCR = 0x02; /*Counter Reset*/
        T1TCR = 0x01; /*Counter Enable*/
        T1CTCR = 0x05; /*Count Pulses*/
        countval = T1TC;
        simplePrintf("%d", countval); /*Print to Display*/

It counts the pulses on the pin fine however the count always seem to start from either 7 or 14 depending on where I place the counter setup code.

Any help would be appreciated.

  • Not sure of your processor, assuming something like LPC2478. looked at a user manual for the LPC214X.

    I see that there is a MCR register bit 1 which tells timer 0 to reset on match condition.

    and there is a Match Register for timer 0, MR0 which holds the counter value that the
    counter is to match when the reset should occur. I don't see anything like that in your code.

  • Also, I would take a look at the system viewer and view your timer peripheral to see
    if you can see the registers. every time you stop the processor the timer values will
    update there values.