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

Clearing my doubts...

I was thinking whether its feasible to use a 8-bit counter with auto-reload to capture the number of peaks detected within 100ms.

Parents
  • If you have hardware that:
    - always divides the crystal frequency with 12
    - and there is no prescaler support
    - and you need the timer to tick at 1ms
    then you would need a 12kHz crystal.

    However, most timers have a large set of options for specifying a frequency, and for setting up how it is expected to be run. That may include support for different clock sources, use of prescalers etc.

    If you want to generate interrupts everh 1ms, then you figure out how many ticks the timer need to tick until 1ms has passed, given the frequency that your timer steps with.

    In this case, you are going to measure the time between heart beats. You only need a calibrated time. It isn't important if your timing manges to measure time with higher resolution than required, as long as you make sure that you know about any timer overflows.

    If the timer doesn't tick at 1ms, then it's enough to know exactly what speed it runs in, to allow you to multiply/divide the results you get with whatever scale factor is needed to convert the time into seconds, milliseconds or whatever you want.

    As suggested earlier, measure he time it takes to capture a fixed number of pulse events. If you use the capture registers to pick up the values from the free-running timer, all you need to do is figure out exactly how many ticks the timer has stepped during these heartbeat intervals. If it ticks at 1MHz, then obviously every tick is worth 1us. If it ticks at 200kHz, then every tick is worth 5us, ...

    Use whatever prescaler options you have to initialize the timer, and use that precision for the timing.

Reply
  • If you have hardware that:
    - always divides the crystal frequency with 12
    - and there is no prescaler support
    - and you need the timer to tick at 1ms
    then you would need a 12kHz crystal.

    However, most timers have a large set of options for specifying a frequency, and for setting up how it is expected to be run. That may include support for different clock sources, use of prescalers etc.

    If you want to generate interrupts everh 1ms, then you figure out how many ticks the timer need to tick until 1ms has passed, given the frequency that your timer steps with.

    In this case, you are going to measure the time between heart beats. You only need a calibrated time. It isn't important if your timing manges to measure time with higher resolution than required, as long as you make sure that you know about any timer overflows.

    If the timer doesn't tick at 1ms, then it's enough to know exactly what speed it runs in, to allow you to multiply/divide the results you get with whatever scale factor is needed to convert the time into seconds, milliseconds or whatever you want.

    As suggested earlier, measure he time it takes to capture a fixed number of pulse events. If you use the capture registers to pick up the values from the free-running timer, all you need to do is figure out exactly how many ticks the timer has stepped during these heartbeat intervals. If it ticks at 1MHz, then obviously every tick is worth 1us. If it ticks at 200kHz, then every tick is worth 5us, ...

    Use whatever prescaler options you have to initialize the timer, and use that precision for the timing.

Children