My program above was wrong. Though, it seems firmware 4.3 beta also have it share of bugs. I tried re-flashing to the older firmware version, 4.2.1, and this corrected code ran perfectly. but when I tried it on firmware v4.3,VS does not even hit the breakpoint, and the debugger just exits suddenly without anything happening.
I guess that firmware 4.3 beta is still buggy. Reverting back to firmware v4.2.1....
This is the correct one: