I have a pic 18F project which has incoming data every 10ms in a word.

The top nibble of the word high byte is flags, either %1111 or 0000 (we can ignore/mask them out)

The lower 12 bits is a value 0-4095

If a button is pressed I modify the 12 bit value and then send it back out again.

If the button is not pressed the data passes through unchanged.

All good so far!


Now if the incoming 12 bit data is say 4095, I want to modify that to be 0 and send it out with a gradual change.

When my button is released I want the same thing to happen in reverse i.e. change from 0 back to the 4095.

I basically want the system to smoothly change from the incoming value to mine and back again in say 500ms.

So maybe increments of 80 every 10ms>

I believe this sort of transition is caused 'bumpless transfer' so was wondering if anyone had any clever ideas or code for it..

Thanks