Shop OBEX P1 Docs P2 Docs Learn Events
SX48 force compare — Parallax Forums

SX48 force compare

Wayne GWayne G Posts: 6
edited 2009-01-14 19:33 in General Discussion
Can any one please suggest a way to force a compare or toggle the compare output while the timer is active on an SX48.

Many thanks

Wayne

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-01-13 17:51
    Wayne,

    Could you please elaborate more on exactly what you’re trying to do?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • BeanBean Posts: 8,129
    edited 2009-01-13 18:29
    Wayne,
    What I do it just toggle the capture pin.
    For example setup the timer to capture on rising edge of either capture1 or capture2 pin.
    Do not connect anything to that pin.
    Make the pin low, then when you want to capture the timer value, make the pin high.

    Are you using ASM or SX/B ?

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ·The next time you need a hero don't look up in the sky...Look in the mirror.


    ·
  • Wayne GWayne G Posts: 6
    edited 2009-01-14 06:31
    Chris / Bean

    I am using both timers to accurately measure a pulse width while also using one compare output to generate a 50% duty cycle square wave· with the same period as the measured pulse.· The measured pulse only has a small duty cycle and I can only use the leading edge as a reference point for the output.

    Other processors I have used contain a 'force compare' function which allows manual toggling of the compare output.· On the SX the only way I can see to manually toggle the compare output is by clearing the timer and this will upset my other calculations.

    I have attached a drawing ot the wave forms.

    Thanks

    Wayne
    800 x 577 - 75K
  • BeanBean Posts: 8,129
    edited 2009-01-14 12:39
    Wayne,
    I'm still not following what you are trying to do. Can you post your code that you have so far ?

    Normally you would just clear the timer. Since the timer is cleared by a compare I don't see how manually clearing the timer would "upset" any calculations.

    How do you know where the falling edge goes on the bottom waveform ? How do you know where the 50% place is before the next pulse ? If it is from the previous pulse, then why not just measure the high time AND the low time to know where to set the timer that generates the bottom waveform ?

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ·The next time you need a hero don't look up in the sky...Look in the mirror.


    ·
  • Wayne GWayne G Posts: 6
    edited 2009-01-14 19:17
    Bean

    I need to know the upper wave form pulse width accurately which means measuring the period and High time using both timers.· Clearing the timer to toggle the output upsets the upper pulse width calculations.

    The bottom wave form has a 50% duty cylce and the leading edge aligns with the top wave form therefore the falling edge is 50% of the upper wave form period (measured from the previous period).

    I neglected to say that I have to use compare #2 for the task because compare #1 pin has to be used as an interrupt input.

    Basically if there is no way to manually toggle the compare without clearing the timer I need to change hardware.

    Wayne
  • BeanBean Posts: 8,129
    edited 2009-01-14 19:33
    I'm sorry I still don't follow... If you could post you code it would probably help alot.

    You say you are using both timers to measure the top waveform. Then you are NOT using a timer to generate the bottom waveform ? If so, then why do you need a compare event to toggle the bottom waveform ?

    You can measure the period by simply enabling the capture on rising edge interrupt, then read the value from the timer capture registers.

    It this point I'm lost as to what you are trying to do.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ·The next time you need a hero don't look up in the sky...Look in the mirror.


    ·
Sign In or Register to comment.