Elapsed Timer findings


Results 1 to 40 of 48

Threaded View

  1. #19
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Elapsed Timer findings

    Ok I was thinking where you said you made the PWM to measure on a scope,
    so had my best go at that sitting here rather than scab the code
    Probably not the most effective with memory or time, but I think the frequency will be correct.
    and it’s probably also more like asm pseudo code at the moment.

    Code:
    ‘start of code somewhere:
    ‘
    flipflip var byte
    
    
    ‘in ISR straight after Ticks is incremented
    ‘
    @ btfsc flipflop ,00 		; 1/2
    @ goto aaaa			; 2
    @ goto bbbb			; 2
    aaaa:				‘
    @ bsf portb, 07			; 1
    @ goto overpwm			; 2
    bbbb:				‘
    @ nop				; 1
    @ bcf portb, 07			; 1
    overpwm:			‘
    @ comf flipflop 		; 1 - but timing doesn’t matter here
    
    ‘instruction time 6 for flip state, 6 for flop state,
    ‘7 for the code to execute no matter the status
    I like the idea the PWM is almost free if you wanted it,
    and there might be a situation you’d want the electrical frequency of the timer.

    It might not have originally been obvious I was setting this up for a pic.. only works up to 20MHz though:
    Code:
    '$FFFF - (((20 / 4) * 10000) - 8) = $3CB7
    ‘might as well fix the constant val too
    
    constval = $FFFF - (((f/4)*10000-7)'
    Though I have not needed to, it’s pointless unless you are varying the pic’s oscillator frequency,
    and also telling the pic program the new osc frequency, or figuring out some other way what frequency the pic is running at.
    That PWM would indicate resolution error at runtime for different osc frequencies.
    Last edited by Art; - 20th May 2015 at 16:02.

Similar Threads

  1. Elapsed Timer Demo
    By Darrel Taylor in forum Code Examples
    Replies: 111
    Last Post: - 29th October 2012, 17:39
  2. SPWM and Elapsed Timer
    By CocaColaKid in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 8th May 2008, 03:16
  3. Darrel Taylor Elapsed Timer
    By rwskinner in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 13th March 2008, 01:22
  4. DT Elapsed Timer
    By rwskinner in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 9th March 2008, 23:17

Members who have read this thread : 9

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

Posting Permissions

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