Hello, and welcome to the forum.
Are you suggesting that Vbat is present whilst Vmicon is not present? If so, you are likely to have in the region of 3 volts continuously applied to the PTA3 pin. If Vmicon is not present, it is possible for an internal (intrinsic) diode to the Vdd rail to conduct, so that the Vdd voltage never reaches a sufficiently low voltage for POR to correctly occur.
Also keep in mind that the reference voltage for the ADC is supplied from Vdd. This would mean that, if an ADC conversion should succeed under these conditions, the 8-bit result would remain at 255, resulting in PTA0 high.
You will likely need additional circuitry to ensure that the voltage applied to PTA3 is clamped to zero in the absence of Vmicon.
I also notice that the circuitry surrounding RED_LED seems a little peculiar - a LED current in the region of 0.1 mA, with a transistor base drive current of about 3 mA. If the LED needs to conduct when PTA4 is low, you might consider using a PNP transistor. For load currents of a few milliamps, the series resistor to the base should usually be somewhat higher than 1k.
Not sure whether you require the additional pullup resistors, where external circuitry is driven by an output pin of the MCU.
Within your code, consider using
if-else constructs.
#define PWM PTAD_PTAD0
if (bat_vol < 200)
PWM = 0;
else
PWM = 1;This should be more efficient than using two separate
if statements.
Regards,
Mac