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: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.Code:X VAR WORD Random X X = X * 1000 X = DIV32 21845 SEROUT2, PORTC.3, 16780, [DEC Y, 13, 10]
Thanks Mackrackit for digging up the posts on RANDOM!
/Henrik.




Bookmarks