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

timers/counter

i want to use an if statment to start a timer n then i want it to tell me how long it been going for and then i want it to reset when it get to a lower value. where do i start.

  • Obviously by reading the documentation for your specific processor. That information tells you how to configure the running speed of the timer. How to start it. How to stop it. How to check the current value.

    You do _not_ start by writing a forum post asking how to start. Forum posts are good when/if you get stuck somewhere.

  • but i dnt know how to do it, like i dont understand how to set the timer up. yes i have looked at the datasheet but unless u know what your looking at its very difficult

  • But there are also often application notes. And both Keil and the chip manufacturer may have great examples.

    What document(s) and what paragraph(s) have you read?

  • LPC2368 User Guide
    iv had a look at the relevant parts of this and i have no idea what to do with it, my lecturer has not really provided us with any examples i can use. what else should i read.

  • Why would you need examples from your lecturer?

    NXP did write the LPC23XX User Manual with the intention that a software developer without knowledge about this chip should be able to use the different features.

    In fact, the majority of LPC23xx chips have been incorporated into real products without any lecturer being involved. The lecturer should be able to help you with common terminology for a microcontroller and for different microcontroller peripherials. But the goal of the project must be for you to spend own time reading through the material available from NXP and Keil.

    Chapter 23 (Timer 0/1/2/3) starts by outlining the registers that needs to be configured, with references to a number of tables. And each register of the timer is then documented broken down into the individual bits.

    The timers requires PCLK_TIMERx to be configured. Chapter 3 (Clocking an power control) describes the different clock options. And the configuration wizard available in the separate tab when you open the startup file allows you to configure the clocking options to get your PCLK_TIMERx to tick at a suitable frequency.

    Since we now finally know that it is a LPC23xx chip - NXP have a large code bundle available for these chips. Have you looked at it?

    And back to an earlier question - have you checked if NXP have any applicable application notes?

  • iv checked all these thing you mentioned, however i suck at this, i have no idea how to even start this even with all your valuable input. its like having the answer put in front of my face but i jsut dont know where to put it in the code or how to use it.

  • im using the blinky example n guna rea range some stuff n call it course work. but how do i use the timer thats in there, explain that n i might be able to get going.

  • As it says.

    Turn on the power to the timer.

    Configure the PCLK you want.

    Then configure the timer prescaler and match values.

    Configure any potential interrupt handler.

    Activate the timer.

    Start processing interrupts, or start polling the running timer.

    All steps are covered in both the user manual and in existing sample programs.