12f675_fuse_about_to_blow!


Results 1 to 40 of 929

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    Hi Dave,
    I missed that second post of yours but Mackrackit covered it. The PIC only deals with integer numbers but there are several tricks around that, here's one:
    Code:
    X VAR WORD
    Random X
    X = X * 1000
    X = DIV32 21845
    SEROUT2, PORTC.3, 16780, [DEC Y, 13, 10]
    As you can see here, the X = X*1000 most likely produces a result that won't fit within a WORD, however PBP (even before the arival of LONG variable) allows you to use the intermediate 32bit result for calculations like this one. So, we multiply X by 1000 and then divide it by 1000*21.845 which is the same as dividing X by 21.845 in the first place. It will truncate whatever is to the right of the decimal point but in this case it means that you'll be off by no more than 1ms.

    Thanks Mackrackit for digging up the posts on RANDOM!

    /Henrik.
    Last edited by HenrikOlsson; - 9th July 2010 at 15:22.

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