Content originally posted in LPCWare by starblue on Mon Jun 01 01:25:53 MST 2015
No, you shouldn't need a mutex.
Such SET/CLR registers exist precisely so that you can set or clear a bit atomically with a single write. It avoids the dangerous read-modify-write, which would indeed need some form of protection.
A common mistake in this context is to use |= instead of =, but that's correct in your example code (maybe not everywhere?).
If the MPU were misconfigured for GPIO it might cause problems (but that would be very unusual). I.e. if GPIO were configured like normal RAM a cache might swallow the first write of two.