Strange serial and pwr led behavior

I have a bit of a strange issue here with a Nano. When I run the code below, It mostly works as expected. When I comment out the Serial.Begin(38400); It still works, but the TX light basically stays on, and pulses brighter about once a second. In both cases, if you change the baud rate in the serial monitor (which never shows anything, as expected by code), the arduino nano seems to reset. Also, when running from battery only, the pwr light pulses about twice a second. It stays on, just gets brighter for a moment. When plugged into usb (VIN is still connected to battery and has power), the PWR light doesn't pulse.

int p1 = 0, p2 = 0, p3 = 0, p4 = 0, check = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(38400);
  analogWrite(9, p1);
  analogWrite(6, p2);
  analogWrite(5, p3);
  analogWrite(3, p4);
  p1 = 30;
  p2 = 30;
  p3 = 30;
  p4 = 30;
  
}

void loop() {
  // put your main code here, to run repeatedly:
  if (check == 0) {
    analogWrite(9, p1);
    analogWrite(6, p2);
    analogWrite(5, p3);
    analogWrite(3, p4);
    check = 1;
  }
}

This code was meant as a test when my previous W.I.P. code started giving me trouble. It would set the values for p1-p4, analogWrite them (as coded), then turn them off for no apparent reason after a random time between about 500ms and 3000ms(not coded, the shutdown is a bug). p1-p4 still had good values when this happened. This is the reason for the check variable and the if statement above, so the analogWrite would only happen once. The previous issue that I was initially testing for (random shutdown) does not happen in the above code.

Hopefully I havn't thoroughly confused everyone, and in case I have: I am not looking to solve my shutdown issue here, thats just explaining the point of the above code. Here are my issues:

  1. TX light on and pulsing with no Serial.begin()
  2. PWR light pulsing when powered by battery only, but not with battery and usb

Each output pin goes through a 390ohm resistor to the gate of a mosfet. The mosfet sits low-side in series with a motor, using the same battery supplying VIN on the nano. These circuits work as expected. Not sure if this matters, but I thought I'd include it just in case.

I fear this nano may already be laying in its coffin waiting for the lid to fall. Unfortunately, it is already mounted on the project, so I'm hoping its fixable. Any ideas?

Thanks,
Kyrle

More Info:
I did some poking around with a DMM. When the TX light is on and pulsing, the RX pin has a little over 6v. This is the only place in the entire circuit with that voltage. The 5v line stays right at 5v. The Tx pin stays around 100mV.

Update:
Decided to check if serial communication was even working. So, I turned everything on and went to plug it in to upload a basic echo serial test. Before plugging it in, I noticed the TX, RX and PWR lights were all on. Pressed reset, the TX light went off, then came back on. When I plugged in the USB, nothing happened, it was not detected and the IDE could not upload the sketch.

I am going to give it a break for the day. Hopefully stepping away will clear my head and give you guys some time to offer ideas. Hopefully I wont be ordering a new nano tomorrow and swapping them out. I'd appreciate any ideas you guys can offer to help me prevent that.

Elryk:
Each output pin goes through a 390ohm resistor to the gate of a mosfet. The mosfet sits low-side in series with a motor, using the same battery supplying VIN on the nano. These circuits work as expected. Not sure if this matters, but I thought I'd include it just in case.

My first guess would be that electrical noise from the motors is causing a reset each time the sketch starts. Try running the sketch without the motors connected to power (leaving the pins connected to the MOSFETs should be OK.
Do the motors, being inductive loads, have snubbing diodes across them?

The entire circuit is no longer working due to the arduino nano issues stated in the updates, however, the issues I was having, were happening whether the motors were running or not. The above sketch has been run keeping p1-p4 at 0 (essentially turning off all motors with the mosfets) with no change other than no movement on the motors. Its not possible to disconnect the motors completely without significant soldering, or removing the nano from the entire circuit. The original issue (TX light on with no serial.begin and plusing led) happened with power to motors, without power to motors, and with the nano totally removed from the circuit.

The Mosfets have protection diodes, however, I did not have diodes across the motor until after the total failure of this last nano. For some reason I wasnt thinking that the mosfet diodes only protected the mosfets, not the reset of the circuit. After the nano stopped working, I did install some diodes across the motors for future protection. So, they do have diodes now, but did not before the nano stopped working. I'm pretty sure this was the initial cause of the problem now (transient voltage spike caused damage), but I'm open to other ideas to check before I power up the new nano on order, both to prevent future issues, and possibly fix the bricked (feathered? lol) nano.

I have already purchased a new nano replacement, but if anyone knows a fix to the updated issue (leds on, wont upload or run), I have 2 nanos with this issue and Id like to try to fix them if possible.