Do you have (or can you add) a debug port (EUSART, SEROUT, DEBUG)?
If so, then print the value of your variable out before calling the write routine, before executing the write command, after executing the write command, read the value back immediately after and print it out again.

Is CB declared as a BYTE?

If you're indexing arrays somewhere then doublecheck that you're not writing outside the range of the array.