Chen Xiao Fan wrote: > I am trying to generate some pseudo random code to add > some randomness for the pulse generation. I found the > following code from PICList archive. However it is > generating random code from 1 to 255 and I am trying to > generate something between 1 to 31 (can be 32, etc). So just AND the 0-255 value with 31. > Are there any simple code to generate arbitrary pseudo > random number (<=8-bit)? I don't know if you would consider it simple, but the HAL_RAND.ASPIC module contains a pseudo-random number generator. It is available in the HAL PIC project from http://www.embedinc.com/pic. Remeber that Embed Inc software releases must be installed in oldest to newest order. I don't think this release has been updated in a long time. If you install it, you must go back and re-install any newer releases you wish to function correctly. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist