XIAO_BLE_Sense(mbed 2.7.2) battery charge and voltage monitor, analogRead(P0_31) does not work

Hi Seeed-Jx,

I checked the LED and LED pin name and analogRead(PIN_VBAT) combination, but the 2/3 combination did not work correctly. In the worst case, the COM port was lost!
Below is the sketch I used to check.

#define LED LED_BUILTIN      // default
//#define LED LEDR                // OK : can read voltage and flush red LED
//#define LED LEDG                // NG : COM port disappears and off green LED
//#define LED LEDB                // OK : can read voltage and flush blue LED
//#define LED P0_26               // NG : can read voltage but always off red LED
//#define LED P0_30               // NG : COM port disappears and on green LED
//#define LED P0_6                // NG : can read voltage but on blue LED

const int analogInPin = PIN_VBAT;
int raw_bat = 0;        // value read from the pot
int v_bat = 0;
uint8_t state = 0;

void setup() {
  Serial.begin(9600);
  pinMode(LED, OUTPUT); 
  pinMode(PIN_VBAT_ENABLE, OUTPUT); 
  digitalWrite(PIN_VBAT_ENABLE, LOW);
}

void loop() { 
  state = 1 - state;
  digitalWrite(LED, state); 
  // read the analog in value:
  raw_bat = analogRead(analogInPin);
  v_bat = (raw_bat * 3 * 3300) / 1024;
  Serial.print("raw = ");
  Serial.print(raw_bat);
  Serial.print(", V = ");
  Serial.print(v_bat);
  Serial.println("mV");  
  delay(500); 
}