As the code stands - the wdt will cause a reboot repeatedly. Your main loop needs to have a delay in it to allow the (co-operative) multi-tasking to work (and there are at least 5 tasks running created by the RTOS)
One option might be to create a separate task (with xTaskCreate) -
(In pseudocode)
.led = false
Loop
.led = !.led
set pin .led
delay 2ms
end loop
But I don't think that a 2ms second delay is long enough - so this technique would work for slower pulse rates but not 500Hz...
So - plan B is to do the job in the timer ISR and toggle the pin every time the ISR is called.
ISR:
$PIN17 = !$PIN17
Note that this isn't 'guaranteed' to give exact times (it relies on the multi-tasking and tasks 'yielding') but I've found this to be pretty good!
Plan C is to either use the SPI or RMT hardware to do the job - perfect if the timing needs to be 'just so' - but rather more involved to write
Martin