DIV32 Questions ...


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614

    Question DIV32 Questions ...

    Hi,

    For my last hair sake ...

    The attached program ( 18F452 @ 4 Mhz ) / PbP 2.47 / MPLAB 7.61a is a RPM counter for 4 Stroke 1 cyl engines ...

    Based on Period Measuring ( w/ TMR3 ) and DT instant interrupts.

    What goes wrong is the DIV32 calculation ... I've verified everything before: period is good, period measurement is right , Stable, and all data furnished to DIV 32 are "legal" ...

    But result is quite FALSE !!!

    The worse thing is I have successfully used DIV32 very often !!!

    Placing DIV32 outside the interrupt stubb gives the same results, even when cancelling interrupts while Dummy and DIV calculating ...

    I'm certainly missing something ... but what ???

    Thanks to our gurus

    Alain

    PS for DARREL: All other parts of the lawn tractor computer work well ... just missing this part !!! Grrrrrr !!!
    Attached Files Attached Files
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Code:
    	Dummy	 = 2500*3000		'Prédiviseur à 8 !!!
    	Vitesse  = DIV32 Periode2
    The constants are being multiplied at Compile Time. So the system registers don't have the values they would if it were multiplied at Run Time.

    If at least one of the numbers is in a WORD variable, it should work better.
    <br>
    DT

  3. #3
    jpohl's Avatar
    jpohl Guest


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel,

    just a question about the use of DIV32 instructions in the same program with your great instant interrupts lib.

    In the documentation one can read the necessary use of disable/enable command before and after the DIV32 instructions.
    Should I use also disable/enable in my program even there is no "On Interrupt" instruction? I use a timer and RBC interrupt via your interrupt interface.

    Thanks in Advance.
    Joerg

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi Joerg,

    Nope, no need to disable interrupts when using DIV32 with DT_INTS.
    System variables are saved and restored on each Interrupt.

    ON INTERRUPT GOTO doesn't do that, so it has problems.

    Good question though.
    <br>
    DT

  5. #5
    jpohl's Avatar
    jpohl Guest


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel,

    very good, thank you for your very fast reply.

    Best Regards,
    Joerg

  6. #6
    Join Date
    Jul 2006
    Location
    USA
    Posts
    26


    Did you find this post helpful? Yes | No

    Default

    Your code doesn't resemble the code example in the manual:

    b = 500
    c = 1000
    dummy = b * c
    a = DIV32 100

    Your code:

    Periode2 = Periode / 2
    Dummy = 2500*3000
    Vitesse = DIV32 Periode2

    The right numbers are not on the stack when the DIV32 occurs.
    Last edited by Brock; - 10th November 2007 at 00:54.

Similar Threads

  1. Problem with Div32
    By lerameur in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 22nd April 2008, 02:54
  2. RPM - DIV32 Problem
    By davewanna in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 11th April 2008, 04:33
  3. Div32
    By Archangel in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 2nd February 2007, 20:26
  4. 32-bit Variables and DIV32, Hourmeter 99999.9
    By Darrel Taylor in forum Code Examples
    Replies: 9
    Last Post: - 23rd November 2006, 07:23
  5. Retrieving Div32 Remainder
    By Darrel Taylor in forum Code Examples
    Replies: 4
    Last Post: - 20th August 2003, 03:53

Members who have read this thread : 1

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