Shop OBEX P1 Docs P2 Docs Learn Events
Mode %10101, how does it work, what does it do? — Parallax Forums

Mode %10101, how does it work, what does it do?

I hope someone can clarify and expand on the vague instructions for this mode and explain how it works. What does the "X[31:0] establishes a minimum number of clock cycles to track periods for." mean in terms of the three modes %10101, %10110, and, %10111? Does it mean the Smart Pin will sample for at least that long before it can trigger the IN flag and I can get "time-from last IN flag = 1" data?

I have set the X register for $0500_0000, or about 3.4 seconds. In mode %10101 the first sampling period takes 5.19 seconds and the second sample period takes 3.47 sec. If the time intervals vary and I don't know how many events occurred during each period, how is the result useful? An example would help me understand how to describe this mode's operation and what someone might use it for. Thank you. --Jon

Comments

  • jmgjmg Posts: 15,144
    JonTitus wrote: »
    I hope someone can clarify and expand on the vague instructions for this mode and explain how it works. What does the "X[31:0] establishes a minimum number of clock cycles to track periods for." mean in terms of the three modes %10101, %10110, and, %10111? Does it mean the Smart Pin will sample for at least that long before it can trigger the IN flag and I can get "time-from last IN flag = 1" data?

    Yes, that defines a minimum 'gate time' but that time will stretch-as-needed, to apply to whole periods
    JonTitus wrote: »
    I have set the X register for $0500_0000, or about 3.4 seconds. In mode %10101 the first sampling period takes 5.19 seconds and the second sample period takes 3.47 sec. If the time intervals vary and I don't know how many events occurred during each period, how is the result useful?
    Good question :)
    On its own, yes, the reported time is only half an answer, so this mode is used paired with at least another smart pin, which collects the whole period count (usually mapped to the same physical pin).

    The two pins collect N whole periods, and dT time for those whole periods, and so Frequency = N/dT in cycles per second.

    Another critical element of this, is that the group of used pins, must be all started on the same SysCLK, so in the link below Chip has this
    		dirh	#msr_pins			'concurrently enable smart pins
    

    JonTitus wrote: »
    An example would help me understand how to describe this mode's operation and what someone might use it for. Thank you. --Jon

    The modes for Time and Periods _10101_ _10111_ are corner stones of Reciprocal Counter design.

    The States mode _10110_ uses the pin as a CountEnable and comes for free, and can be used to report duty cycle when divided by the measurement time from a pin in mode _10101_

    Chip's example using these modes :

    https://forums.parallax.com/discussion/170882/reciprocal-counter-demo/p1
  • evanhevanh Posts: 15,187
    The difference between them being which of the three groups they fall under:
    	SPM_TIM_OVER	= %10101_0		' interval: of A-B pulses/steps, for at least X duration
    	SPM_ACC_OVER	= %10110_0		' accumulate: A-B pulses/steps, for at least X duration
    	SPM_CNT_OVER	= %10111_0		' count: A-B pulses/steps, for at least X duration
    

    Yes, you've noted the key difference from earlier similar modes that don't have the minimum duration.

Sign In or Register to comment.