Simple asm delay ?


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1
    Join Date
    Apr 2006
    Location
    GearSweaterMountain, The Netherlands
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Dear Jerson & Bruce,

    I could not get here earlier, sorry. I appreciate your efforts !

    Jerson, if i declare the delay variable as a byte, it takes even longer.
    I just don't understand .. The delay macro i found works perfect if given a number straight from the call, if it is fed by a variable the delay jumps to 20 or 30us. It also seems that the delay is fixed after that, if i compile @ wait 1000, it delays a perfect 1000 cycles, if i compile @ wait ledred (i.e. ledred = 100) it delays 20uS no matter what ledred is ?

    Bruce, your asm code also does the trick, perfect 1us or 50us delays, pretty neat. But it also suffers from the same problem. If i compile @ Delaycycles 200 if works perfect, if i compile ledred var byte, ledred = 200, @ delaycycles _ledred it gives a delay of 33uS no matter what the value of the leded var is ??

    Apart from that, i need to do a delay between 1 and 1000uS, using tmr0 the max delay will be 256, and i can use the Bruce asm up to 512, the ASM code i posted earlier can go up to about 1024.

    I would use the 16-bit TMR1 if it was available but i need that to do a 100Hz sync (count) interrupt...

    Any ideas ?

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


    Did you find this post helpful? Yes | No

    Default

    @ delaycycles _ledred it gives a delay of 33uS no matter what the value of the leded var is ??
    That's because when you pass _ledred to the macro as the argument, it uses the 'address'
    of ledred, and not the actual value in RAM. Look at the address PBP places ledred at to see
    why that happens.

    You can't put a macro inside a loop with a variable as the argument. What you're looking to do just
    isn't possible (as far as I know) with a macro inside the loop, and calls to any .asm routine, timer, etc,
    just aren't going to give you from 1uS to 1000uS delay periods you need immediately after
    placing a value on GPIO.

    I would re-think the whole process if I'm stuck at 8MHz, or switch osc speed & PIC to support using
    the pauseus commands.
    Last edited by Bruce; - 13th November 2009 at 23:42. Reason: Macros
    Regards,

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

  3. #3
    Join Date
    Apr 2006
    Location
    GearSweaterMountain, The Netherlands
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Hi Bruce,

    Thank you for your detailed answer ! All is clear now.

    I have adapted the code in a way that the led's never go below 12uS, that way the 'color' switch on and off effect (color switches on for 12uS instead of 1uS) does not occur. This makes the colors somewhat more pastel, but it is still a smooth fade and a cool effect.

    And, yes, if i'm going to make a new design i will certainly use a larger external osc ..

    Thanks for all your answers and information !

    Best regards,
    UB

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


    Did you find this post helpful? Yes | No

    Default

    Grab a new 8-pin PIC12F1822 with 32MHz internal osc when they come out. Then you can
    get PAUSEUS down to 2uS. These even have an onboard EUSART.
    Regards,

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

  5. #5
    Join Date
    Apr 2006
    Location
    GearSweaterMountain, The Netherlands
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Yep, if only it had eeprom .... :-(

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


    Did you find this post helpful? Yes | No

    Default

    The preliminary specs state it does. Data EEPROM (bytes) 256
    Regards,

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

  7. #7
    Join Date
    Apr 2006
    Location
    GearSweaterMountain, The Netherlands
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    You are right ! Missed that one, sorry ..

    Will order some samples as soon as possible, hoping that support for the part in PBP will be available soon ..

    Best regards,
    UB

Similar Threads

  1. 16F628A - Stops if release power switch.
    By dene12 in forum General
    Replies: 16
    Last Post: - 14th February 2009, 07:57
  2. Old and beyond help ?
    By DavidFMarks in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 11th December 2008, 15:23
  3. RF Transmitter
    By et_Fong in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th October 2005, 16:34
  4. Memory Space of the PIC16F84...
    By Tear in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 1st July 2005, 19:55
  5. Problem with saving to EEPROM...
    By Tear in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 1st July 2005, 00:10

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