A microcontroller apparatus comprising: a microcontroller circuit comprising a plurality of output ports, each output port having an associated high-side switch electrically connected between the output port and a high-side DC voltage rail and an associated low-side switch electrically connected between the output port and a low-side DC voltage rail, wherein said high-side switches and said low-side switches each comprise a MOSFET switch with a body diode; a processing module configured to be powered, in use, by the high-side DC voltage rail and the low-side DC voltage rail; and a capacitance (205, 501) electrically connected to the high-side DC voltage rail; wherein at least one output port of said plurality of output ports is configured to output a control signal to control at least one aspect of operation of a host device and the processing module is configured to control switching of the associated high-side switch and low-side switch of the at least one output port so as to output said control signal; and wherein said plurality of output ports further comprises a first output port configured to receive, in use, an AC waveform and the processing module is configured to monitor a phase of the AC waveform and to control switching of the associated high-side switch and low-side switch of the first output port based on the phase of the AC waveform so as to provide a rectified voltage between the high-side DC voltage rail and the low-side DC voltage rail; characterized in that the processing module is configured to: monitor a voltage of the AC waveform at the first output port and a voltage at the high-side DC voltage rail; maintain the associated high-side switch of the first output port in a turned-off state when the monitored voltage of the AC waveform at the first output port is between zero and the monitored voltage at the high-side DC voltage rail; and maintain the associated high-side switch of the first output port in a turned-on state when the monitored voltage of the AC waveform at the first output port is greater than the monitored voltage at the high-side DC voltage rail. a microcontroller circuit comprising a plurality of output ports, each output port having an associated high-side switch electrically connected between the output port and a high-side DC voltage rail and an associated low-side switch electrically connected between the output port and a low-side DC voltage rail, wherein said high-side switches and said low-side switches each comprise a MOSFET switch with a body diode; a processing module configured to be powered, in use, by the high-side DC voltage rail and the low-side DC voltage rail; and a capacitance (205, 501) electrically connected to the high-side DC voltage rail; wherein at least one output port of said plurality of output ports is configured to output a control signal to control at least one aspect of operation of a host device and the processing module is configured to control switching of the associated high-side switch and low-side switch of the at least one output port so as to output said control signal; and wherein said plurality of output ports further comprises a first output port configured to receive, in use, an AC waveform and the processing module is configured to monitor a phase of the AC waveform and to control switching of the associated high-side switch and low-side switch of the first output port based on the phase of the AC waveform so as to provide a rectified voltage between the high-side DC voltage rail and the low-side DC voltage rail; monitor a voltage of the AC waveform at the first output port and a voltage at the high-side DC voltage rail; maintain the associated high-side switch of the first output port in a turned-off state when the monitored voltage of the AC waveform at the first output port is between zero and the monitored voltage at the high-side DC voltage rail; and maintain the associated high-side switch of the first output port in a turned-on state when the monitored voltage of the AC waveform at the first output port is greater than the monitored voltage at the high-side DC voltage rail.