1 year, 6 months ago.

MAX32630FTHR Serial is not work when i reconnect

include the mbed library with this snippet

#include "mbed.h"
#include "max32630fthr.h"
#include "USBSerial.h"
#include "bmi160.h" //IMU header

Serial pc(USBTX, USBRX);
MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
USBSerial microUSB; 

DigitalOut gLED(LED2,LED_ON);

int main()
{
      while(1)
       {

        if(pc.readable())
        {
                char UART_BUFF[10];
                int UART_BUFF_IDX = 0;
                int UART_DATA = 0;
                char UART_temp_data = 0;
                
                
                while(UART_temp_data !='\n')
                { 
                    UART_temp_data = pc.getc();
                    UART_BUFF[UART_BUFF_IDX] = UART_temp_data;
                    UART_BUFF_IDX++;
                }       
                UART_BUFF[UART_BUFF_IDX] = '\0';
                UART_DATA = atoi(UART_BUFF);
                        
                microUSB.printf("%d\n",UART_DATA);

        }
        }
}

Hi I am Endrew. I have the code above and it works fine.

The first thing I'm wondering is that when I connect to the Serial Terminal at first time (like Arduino or Putty) it works fine.

However, if I try to connect the Serial Terminal again, the Serial will die.

Just USBSerial works well. Therefore, the MAX32630FTHR does not seem to die.

When I reconnect the Serial cable it works fine again.

I would like to keep the Terminal running and working well without having to reconnect the cable.

Be the first to answer this question.