Integer Arithmetic Assistance Required


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Integer Arithmetic Assistance Required

    Hi,
    One possible solution
    Code:
    Dummy VAR WORD
    
    Dummy = Red * Pot4
    ScaledRed = DIV32 1024
    
    Dummy = Green * Pot4
    ScaledGreen = DIV32 1024
    
    Dummy = Blue * Pot4
    ScaledBlue = DIV32 1024
    /Henrik.

  2. #2
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: Integer Arithmetic Assistance Required

    Hi Henrik,

    I knew there had to be a simple way of doing this, I just couldn't figure it out on my own - thank you!
    Will the DIV32 command be affected if I am using DT-Interrupts? What happens is an interrupt occurs between the two arithmetic operations?
    Dummy = Red * Pot4
    Interrupt occurs here
    ScaledRed = DIV32 1024

    Cheers
    Barry
    VK2XBP

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Integer Arithmetic Assistance Required

    It shouldn't have any effect. DT-INTS saves the system variables when entering the ISR so even if an interrupt happens in between the multiplication and the division AND the ISR happens to use the same system variables (R0 and R2 IIRC) holding the 32 bit result from the multiplication no harm is done since the content of those variables are restored by DT-INTS when exiting the ISR.

    /Henrik.

  4. #4
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: Integer Arithmetic Assistance Required

    Hi Henrik,

    The DIV32 approach worked perfectly - thank you.

    Cheers
    Barry
    VK2XBP

Similar Threads

  1. Assistance Required with VB.net
    By malc-c in forum Off Topic
    Replies: 32
    Last Post: - 11th September 2010, 18:26
  2. Resolution integer math assistance?
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th January 2010, 03:01
  3. VB.net and bit arithmetic
    By Ron Marcus in forum Off Topic
    Replies: 1
    Last Post: - 7th May 2008, 04:38
  4. keypad lcd and arithmetic help
    By csubroncs in forum General
    Replies: 0
    Last Post: - 27th January 2004, 17:18

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