TMR0 interrupt. Counter pauses?


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2011
    Posts
    5

    Default TMR0 interrupt. Counter pauses?

    Hi everybody,
    I want to obtain servo control pulses. 50Hz (1520us center puls) using a 16F88 TMR0 interrupt. Running 8MHz (therefore 2MHz from FOSC/4) with 1/256 prescaler.

    In the interrupt handler right after entry, I preload the TMR0 counter then PULSOUT. It is a very basic code.

    It seems that the counter pauses during the PULSOUT because the outcoming signal's period is lengthened by the puls duration.

    I tried different TMR0 values. Some does work fine some doesn't. By working fine I mean that the outcoming signal's period (therefore frequency) doesn't change with regard to puls duration.

    Any idea?

    Code for the interrupt handler:

    DISABLE
    INTERRUPT_HANDLER:
    TMR0=160 'Tried different values here. Some work fine some doesn't.

    PULSOUT SERVO, Duration 'SERVO is a SYMBOL for PORTA.2
    LOW SERVO 'Just a precaution...

    INTCON.2=0 'Interrupt flag cleared.
    RESUME
    ENABLE

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: TMR0 interrupt. Counter pauses?

    Quote Originally Posted by Kaya Onur View Post
    Hi everybody,
    I want to obtain servo control pulses. 50Hz (1520us center puls) using a 16F88 TMR0 interrupt. Running 8MHz (therefore 2MHz from FOSC/4) with 1/256 prescaler.

    In the interrupt handler right after entry, I preload the TMR0 counter then PULSOUT. It is a very basic code.

    It seems that the counter pauses during the PULSOUT because the outcoming signal's period is lengthened by the puls duration.

    I tried different TMR0 values. Some does work fine some doesn't. By working fine I mean that the outcoming signal's period (therefore frequency) doesn't change with regard to puls duration.

    Any idea?

    Code for the interrupt handler:

    DISABLE
    INTERRUPT_HANDLER:
    TMR0=160 'Tried different values here. Some work fine some doesn't.

    PULSOUT SERVO, Duration 'SERVO is a SYMBOL for PORTA.2
    LOW SERVO 'Just a precaution...

    INTCON.2=0 'Interrupt flag cleared.
    RESUME
    ENABLE
    If the TMR is disabled when entering the INT, then it is not counting. Therefore thr duration of PULSOUT will change the timing.

    Move PULSOUT to your main loop. Set a flag in your INT. Then in your main loop, if the flag is set, execute PULSOUT and clear the flag.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  3. #3
    Join Date
    Feb 2011
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Re: TMR0 interrupt. Counter pauses?

    Quote Originally Posted by cncmachineguy View Post
    If the TMR is disabled when entering the INT, then it is not counting. Therefore thr duration of PULSOUT will change the timing.

    Move PULSOUT to your main loop. Set a flag in your INT. Then in your main loop, if the flag is set, execute PULSOUT and clear the flag.
    Thank you Bert.

    I didn't know that DISABLE had this effect. I will try this ASAP.

    In the PBP help documentation, they say that DISABLE doesn't actually generate code. So I am a bit confused how it stops the counter without generating any code.

    Thank you very much.

  4. #4
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: TMR0 interrupt. Counter pauses?

    I am not certain it is, I ment to say "If it is disabled". But in any event you should move the PULSOUT
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default Re: TMR0 interrupt. Counter pauses?

    DISABLE doesn't generate code, but it does keep PBP from placing interrupt checking code in your interrupt handler. It doesn't stop any timers.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  6. #6
    Join Date
    Feb 2011
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Re: TMR0 interrupt. Counter pauses?

    Quote Originally Posted by Bruce View Post
    DISABLE doesn't generate code, but it does keep PBP from placing interrupt checking code in your interrupt handler. It doesn't stop any timers.
    My pleasure...

    So how would you think on the lengthened period issue ?

    I removed the PULSOUT into the main loop as Bert said. It looks OK now.

Members who have read this thread : 2

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts