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?
/* 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.)
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.
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
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.
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)?