hello,i use a l432kc component and i need to communicate with a xbee s2c through UART and i don’t know what is wrong with my program ,some one can help me?
I correctly have connected the pins to the l432kc (Pin1xbee(3v3),Pin2xbee(txl432kc),Pin3xbee(rxl432kc),Pin10xbee(gnd)
here’s my program
/* mbed Microcontroller Library
- Copyright (c) 2019 ARM Limited
- SPDX-License-Identifier: Apache-2.0
*/
#include “mbed.h”
#include “platform/mbed_thread.h”
// Blinking rate in milliseconds
#define BLINKING_RATE_MS 1000
RawSerial pc(USBTX,USBRX);
RawSerial xbee(PA_9,PA_10);
char car_recu;
bool ok;
void callback_ex()
{
// Note: you need to actually read from the serial to clear the RX interrupt
car_recu=(xbee.getc());
ok=true;
// led = !led;
}
int main()
{
pc.baud(9600);
xbee.baud(9600);
while (true) {
thread_sleep_for(BLINKING_RATE_MS);
xbee.printf("+++");
while (true) {
if (ok==true) {
pc.putc(car_recu);
ok=false;
}
}
pc.printf("+++");
thread_sleep_for(5000);
}
}