Low frequency output


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    That was what I was thinking. I could have an infinite loop containing a few pin high/pin low commands, and a pause command, where the pause variable is set in the interrupt routine.
    yep it could be this. You can use interrupt for port pin level change for that... surely. A little problem may happen... latency to answer to interrupt. In this case, you'll fix it really simple using a loop delay let' say with PAUSEUS 10... about 10Usec.

    Here's a simple snippet to explain.

    Code:
    main:
    ......
    Frequency=250 ;have 250Hz as frequency
    Period_Delay_ms=1000 / frequency ;calculate period delay
    Half_Period_ms=Period_Delay_ms/2 ;calculate half period delay
    gosub PseudoPWM
    .....
    
    PseudoPWM:
    For a=0 to Half_Period_ms
         For b=0 to 100
               HIGH PORTB.0
               PAUSEUS 10
         Next
    next
    
    For a=0 to Half_Period_ms
         For b=0 to 100
               LOW PORTB.0
               PAUSEUS 10
         Next
    next
    return
    in the above, if any interrupt happen in the PseudoPWM, it will be answer in *about* 10 Usec

    for frequency acurracy you'll have to measure the frequency out regarding the frequency you're suppose to have with your delay and play with PAUSE delay, NAP or @NOP to fine tune the error percentage. Once it's done everything will work just fine.

    regards
    Last edited by mister_e; - 16th November 2004 at 16:39.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Old and beyond help ?
    By DavidFMarks in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 11th December 2008, 16:23
  2. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 18:27
  3. Serious Serial Situation Setbacks...
    By Dansdog in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th February 2007, 04:46
  4. inaccurate frequency using TMR1 PI18F452
    By nkarpovich in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 14th October 2006, 17:22
  5. 4-line LCD Help - using PortA instead of B
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 28
    Last Post: - 31st March 2005, 04:14

Members who have read this thread : 0

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