Hi
It looks like you are running on the internal oscillator, but have forgotten to include the necessary C-Code to enable such. You can see I have included it in the attached.
I simulated by going to Debug>Step Into.
You will see the C-code circled and I'm monitoring all variables

- Screenshot 2026-02-07 170922.jpg (100.28 KiB) Viewed 623 times
Stepping through on first run, you can see the variable change state correctly.

- Screenshot 2026-02-07 171246.jpg (85.52 KiB) Viewed 623 times
The program stays in that branch until the switch is activated. Note that when you switch, the branch enables a timer interrupt for as long as the switch is activated. Timer interrupts do not simulate very well on a PC as your PC is running far, far faster than 4MHz and your PC is doing a ton of stuff in the background. It should be OK on hardware.
Hope this helps