Serial.end() won't restart after use as GPIO

Hi everyone,

I was testing the Serial.end() + Serial.begin() methods, and it was working nicely (I could send something, end the Serial, restart it with begin, send something again).

The problem comes when I try to use the pin TX as a GPIO. I used this code :

void setup()
{
uint8_t buff[] = { 1, 2, 3, 4 };
Serial.begin(115200);
Serial.write(buff, 4);
delay(50);
Serial.end();
pinMode(1, OUTPUT);
digitalWrite(1, HIGH);
delay(50);
Serial.begin(115200);
Serial.write(buff, 4);
}

In this case I don't get the second message. Does anyone know what's wrong ? Thank you for your help !

It seems to be link to the PIO_PER register. If I set the PIO_PDR register, it seems to work again.