You understood right. The pins with the tilde (~) symbol are pins which are linked to an hardware PWM module (i.e. timer). Since it is ana hardware module, it is independantindependent of whatever your CPU does. As such, if you are stuck in a delay, your hardware PWM will still continue to generate the proper output signal. A contrario On the other hand, a software PWM (one that you would generate with a manual pin toggling) would be interrupted by your delay.
Most of the time, you should prefer hardware PWM over software PWM for many reason:
- It's more reliable;
- It consumes less power (you could sleep your MCU while still generating PWMs);
- It allows you to do something else instead of servicing the switching;
- It allows for larger frequencies, because you can typically get frequencies up to your MCU's operating frequency, while a software emulation involves a few operations, so you are not able to keep-up; up;
- It's more accurate: the hardware PWM is simply a divider on your MCU's operating frequency, while software PWM uses CPU instructions, which require branching. Since it is compiled code, it is more or less deterministic, so your duty cycle would not be exactly the one you expect (near, but not perfect nor stable if doing something else at the same time).