On Thu, Aug 27, 2015 at 2:46 PM, smplx wrote: > >From what I've read from the description of BAM, if I were doing this in= C > I would do it like this: > > // globals > unsigned char bit_cnt, bit_mask, value_out; > > void set_BAM(unsigned char val) > { > // disable interrupts - how do you do this in XC8? > > bit_cnt =3D 1; > bit_mask =3D 0x80; > value_out =3D val; > > // enable interrupts > } > > void service_BAM() > { > bit_cnt--; > > if (bit_cnt =3D=3D 0) > { > if ((bit_mask & 0x80) =3D=3D 0) > { > bit_mask <<=3D 1; > } > else > { bit_mask =3D 1; > } > > bit_cnt =3D bit_mask; > > // I'm assuming the output pin is defined at compile time > > if ((value_out & bit_mask) =3D=3D 0) > { > // reset output pin > } > else > { // set output pin > } > } > } Hi Sergio, Thanks for the ideas. Just for reference, in xc8 you can enable and disable interrupts by using ei() and di() respectively. For my BAM code I'm hoping to do 8 channels at once, so I'll be preprocessing the current dimmer value of all channels to make a single variable that holds the state of all channels for any given time slice. Hopefully it works out! Josh --=20 A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools. -Douglas Adams --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .