SX1272MB2DAS Shield: Cannot read debug messages from SX1272PingPong

I’ve got two B-L475E-IOT01A2 boards with SX1272MB2DAS Shields. I’ve compiled the SX1272PingPong example and installed it on both boards. The LED’s on both boards are synching in intervals, so I assume that they are talking to each other (Ping…Pong). The debug message flag is set to 1:

/* Set this flag to ‘1’ to display debug messages on the console */
#define DEBUG_MESSAGE 1

, but I am unable to see anything on a console. What console anyway? Debug Console, Serial console?
I tried introducing code so that I can transfer data via serial using HAL_UART_Transmit, but then I get error messages. How can I find out what is going on, and how can I introduce serial comms into the loop so that I can check whether the results are ok?

Hello Dirk,

/* Set this flag to ‘1’ to display debug messages on the console */

That mean, the default STDIO, witch is set on your board on these pins and it is connected to the onboard ST-Link. So if you have already installed ST’s driver for the VCP via the ST-Link, then just run some serial monitor and set the correct COM port.

The debug function what is implemented in the code from the debug.h, can be replaced with the standart printf (without or with some serial API according to related Mbed OS version from the documentation.)

BR, Jan

Hello Jan,

thanks for answering. I placed printf into the debug function in debug.h:
static inline void debug(const char *format, …)
{
#if DEVICE_STDIO_MESSAGES && !defined(NDEBUG)
va_list args;
va_start(args, format);
vfprintf(stderr, format, args);
va_end(args);
#endif
printf (format, “%s”);
}

Then I opened a TeraTerm console on port 33 (speed: 115200) 11, this is what I get:
> LORA Mode <

Starting Ping-Pong loop

++ MbedOS Error Info ++
Error Status: 0x80010133 Code: 307 Module: 1
Error Message: Mutex: 0x10000860, Not allowed in ISR context
Location: 0x800DBCD
Error Value: 0x10000860
Current Thread: main Id: 0x1000201C Entry: 0x800AF79 StackSize: 0x1000 StackMem: 0x10000BA0 SP: 0x20017E78
For more info, visit: mbedos-error
– MbedOS Error Info –

                                                              = System will be rebooted due to a fatal error =
                              = Reboot count(=129) reached maximum, system will halt after rebooting

For a code what you want to place here, please use method like bellow.

```
// your code here
```

I think your printf format is not correct and it is not needed to place the printf() to the debug.h, just replace

debug( "...Pong\r\n" );

with

printf("...Pong\r\n");
//or
const char *strc = "...Pong"
printf("%s\r\n", strc);

However, about the crash.
That usually occurs when the printf method is called from interrupt context (in this case probably OnTxDone, OnRxDone and so on). Because methods like are printf, getc, putc, write, read and so on, are usually secured by a mutex, and the mutex is “Not allowed in ISR context”.
You can try to solve that via Mbed OS bare metal profile. That will disabled the RTOS in the MbedOS = no Mutexes.
Another option is use the EventQueue

Example:

#include "mbed.h"

EventQueue queue(32 * EVENTS_EVENT_SIZE);
Thread t;
Ticker tic;
DigitalOut led(LED1);

void tic_cb() {
    /* everything inside is in the context of interrupt*/
    
    // here you do something magic
    
    //printf("Job done!\n");             /* That is not allowed */
    queue.call(printf,"Job done!\n");    /* Way of eventqueue will take it out of context of interrupt. */
}

int main(void) {
    printf("Start\n");
    t.start(callback(&queue, &EventQueue::dispatch_forever));
    tic.attach(&tic_cb, 1s);
    
    while(1){
        led = !led;
        ThisThread::sleep_for(500ms);
    }
}

When you switch to standard printf the system will crash with first call of it.

BR, Jan

I tried compiling PingPong in the Embed IDE on my computer, but then I get the above error messages.
When I compile the example PingPong online, and flash the .bin file on the board it works.

When I tried extending the PingPong example for temperature reading, I get the following error:

 Error: Target "DISCO_L475VG_IOT01A" is not recognized

what does this mean?

I am not sure but usually the error come because is used an old version of Mbed library where the target was not implemented yet. So try to update Mbed library and you will see.

Thanks I updated Mbed, and that no longer flagged as an error. But now I am getting this:

Error:   #define MBED_RAM_SIZE               0x00018000

Truly I have no idea the description of the error doesn’t tell me anything.
Can you share informations about libraries what you exactly use (revision/version of Mbed library)?

BR, Jan