Shop OBEX P1 Docs P2 Docs Learn Events
Counter Module question? — Parallax Forums

Counter Module question?

msiriwardenamsiriwardena Posts: 301
edited 2014-02-20 11:08 in Propeller 1
I am trying to understand Counter module applications.I am reading through "Propeller Education Kit Labs" and in P 123 :

Counter Modules and Circuit Applicaions Lab – Page 123


3) Store 1 in the FRQ register so that the phsa register will get 1 added to it for every clock tick
that P17 is high:

frqa := 1

1 isn’t the only useful FRQ register value. Other FRQ register values can also be used to prescale the
sensor input for calculations or even for actuator outputs. For example, FRQ can instead be set to
clkfreq/1_000_000 to count the decay time in microseconds.
frqa := clkfreq/1_000_000

What I don't understand is if "frqa" is added to "phsa" every "clock tick" The interval between the each add is "one clock tick" but you are adding "clkfreq/1_000_000"
every "clock tick".
To get decay time in mocroseconds: - then you have to add 1 microsecond every microsecond to "phsa" to get the decay time in microseconds.

Do I make sense.??? or I am confused ??

Please explain clearly.

Thanks,

Siri

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-02-20 09:47
    No, it doesn't make sense and is wrong. To get the decay time in microseconds, you'd have to add 1_000_000 / clkfreq at every clock tick. But that's impossible, since the number is less than one.

    The way to solve this is to take the total count, when frqa == 1, and divide it by clkfreq / 1_000_000 after the fact.

    -Phil
  • msiriwardenamsiriwardena Posts: 301
    edited 2014-02-20 10:15
    @ Phi

    I understand : when frqa:= 1 1 is added to phsa every clock tick

    When FRQA is set to ---> frqa := clkfreq/1_000_000 - what is added to "phsa" every clock tick

    Please can you clarify this.

    Thanks ,
    Siri
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-02-20 10:55
    When FRQA is set to ---> frqa := clkfreq/1_000_000 - what is added to "phsa" every clock tick
    If clkfreq == 80_000_000, then 80 is added at every clock tick.

    -Phil
  • msiriwardenamsiriwardena Posts: 301
    edited 2014-02-20 11:08
    @ Phil,

    Thanks - Now I understand clearly.

    Siri
Sign In or Register to comment.