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.

Parents
  • 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.

Reply
  • 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.

Children