7 years, 6 months ago.

MAX32630FTHR hangs on serial buffer overflow and on serial interrupt

Hi mbed community,

I'm new to mbed and using the MAX32630FTHR board. I'm working on a project to build personal locator beacon around a RockBlock Iridium SatComm module and a uBlox 6M GPS, both of which use 9600 bps serial. I've successfully transmitted and received with both devices so I know the hardware is functional. In each case I've relied on the code being simple enough to use serial.readable(), wait while data arrives and process immediately. Presumably with minimal buffering.

Now I know all the bits work and I have some basic mbed skills the project has become more complex and I can't wait around all the time for serial data. So I either need to rely on some buffering or use interrupt.

The first problem I encountered was when I was too slow to service the serial interface, and presumably, the buffer overflows. My assumption was that GPS data would simply get dropped if I ignored it when I didn't need it but I found that the MAX32630FTHR would hang once the serial buffer was full. I've searched the forums, but it seems that relatively few people are using the MAX32630FTHR and I haven't been able to find any discussions regarding "normal" behaviour for serial ports on this platform. My first question: Has anyone else had issues with lockups with Serial on the MAX32630FTHR?

I looked at some of the alternative and extended serial libraries, but many of these don't seem to support the MAX32630 yet. So I decided not to let the buffers overflow and implement serial interrupts instead. After much frustration and failure, I realised that when the interrupt function was called, again a lockup. This is the case even if I use the model serial interrupt example below.

Attach to RX Interrupt

#include "mbed.h"
 
DigitalOut led1(LED1);
DigitalOut led2(LED2);
 
Serial pc(USBTX, USBRX);
 
void callback() {
    // Note: you need to actually read from the serial to clear the RX interrupt
    printf("%c\n", pc.getc());
    led2 = !led2;
}
 
int main() {
    pc.attach(&callback);
    
    while (1) {
        led1 = !led1;
        wait(0.5);
    }
}

The code runs initially with a flashing LED. The instant a character arrives on serial the LED state is locked. In the above example, USB serial is used, but I observed the same behaviour with UART2 and another interface (P5_3,P5_4).

Anybody else using a MAX32630FTHR and seen this behaviour or have any suggestions as to an approach to identifying what's going on?

Try putting a "while pc.readable() {}" loop in your callback, surrounding the printf and led2 lines. You need to read all of the available characters in your callback, not just one.

posted by Just Gary 08 Nov 2019

1 Answer

5 years, 5 months ago.

Hello I have the same issue even on very simple program using serial both MBed2 and MBed-Os. Did you find any solution ?

Accepted Answer