I would recommend to have a look to the preprocessor output and to the disassembly listing at that code position.
Those two listings can be created with the context menu in the CW ide, I always check them first when I see some unexpected behavior.
With the current information the problem could be just about anywhere, so really not enough information. The code looks basically ok, but as it is only a non complete code snippet, there are many reasons why it would not work as expected.
Daniel