external crystal being perturbed
hi there. I have a stm32 microcontroller which is ran using HSE. the crystal is 11.0592MHz. the code is simple and is about reading some GPIO_Input and send and receive via UART.
so far good and simple.
this board is actually a relay card. it has 8 relays on it and each relay's NO-NC_COM are left for customer to connect and use.
relays are magnetized this way: a 24v is connected to one end of bobbin and the GND is ran by microcontroller.
in some scenarios it is reported that when a relay is connected to a heavy load, the UART is not working as promised. further research showed that connecting heavy load, causes noise on external crystal and although the UART is working but because of false clock produced by perturbed crystal the packet arrived has false bytes.
what I did was that I used internal crystal of microcontroller and this way the noise of heavy loads did not have any effect on UART.
but is there a way that any time that my external crystal is perturbed, I figure it out someway(maybe in a interrupt) and fix it in my code(maybe re-initialize HSE again)?
thanks for your help