Pic not timing correctly


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2007
    Location
    Denmark
    Posts
    28

    Default Pic not timing correctly

    First of all, I want to say hello to everybody in these forums. Thanks for giving some of your time to helping out people.

    I have an Issue with all the pics I program. I've read that when you work with interrupts in PBP, when they are activated, they wait for the last command to finish before they begin.
    That is, if you are in a 50 second pause when it happens, you'll have to wait for the pause to end before the interrupt becomes active.

    To avoid this all you have to do is to use the For..next command. Here is where I have trouble.

    When I do:
    ----
    pause 1000
    ----
    It pauses exactly for 1 second, but when I try to do the same using for...next:
    ----
    for b0 = 0 to 1000
    pause 1
    next b0
    ----
    It doesn't pause for 1 second, it speed up and pauses for like 0.3 seconds. I've tried everything but nothing fixes this, I've tried with several pics and they all have the same problem.

    By the way, I use them in Internal oscillator mode but I also tried using a 4 mhz crystal and it happened again.

    thanks again!

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


    Did you find this post helpful? Yes | No

    Default

    B0 have to be a WORD sized variable unless it will only consider the 8 less significant bits. In this case 1000 will be considered as 232... hence why your timing is off. (232/1000=0.232 of expected value)

    You can override most problem using ASM interrupt or Brilliants Darrel's Instant interrupts.
    Steve

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

  3. #3
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    atwoz , What type of variable is "b0" defined as? If it is declared as a byte it is only counting to 255..... Declare it as a word..

    Dave Purola,
    N8NTA

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


    Did you find this post helpful? Yes | No

    Default

    euh yeah... 255 if in a loop... OOPS!
    Steve

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

  5. #5
    Join Date
    Dec 2007
    Location
    Denmark
    Posts
    28


    Did you find this post helpful? Yes | No

    Default thanks

    Yeah, that was the problem, thanks a lot for your time!

Similar Threads

  1. Midi, Interrupts and Pic better than SX28?
    By Lajko in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 27th September 2008, 00:26
  2. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 21:01
  3. About timing in pic basic pro
    By din_kt in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 4th October 2007, 03:09
  4. PIC 12c509 - No External timing components
    By stay_aliveuk in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th September 2006, 17:20
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23: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