Hi all,
I am having trouble interfacing the HM-10 bluetooth module on my FRDM-KL03Z board.
It works wonderfully with my arduino uno using RX/TX, but I would like to send AT commands just using my KL03Z board, but not sure where to start?
I am using KSDK 1.1.
Thanks :smileyhappy:
Hi,
The most update ksdk is 2.3, you can download it from https://mcuxpresso.nxp.com/en/welcome.
There is plenty of UART demo in the package. The path is SDK_2.3_FRDM-KL03Z\boards\frdmkl03z\driver_examples\lpuart
Regards,
Jing
Hi jingpan, I have got the ksdk 2.3 working, but my HM-10 is still not responding with this board. I am using the following code:
#include "board.h"
#include "fsl_lpuart.h"
#include "fsl_device_registers.h"
#include "fsl_debug_console.h"
#include "pin_mux.h"
#include "clock_config.h"
/*******************************************************************************
* Definitions
******************************************************************************/
#define DEMO_LPUART LPUART0
#define DEMO_LPUART_CLKSRC SYS_CLK
#define DEMO_LPUART_CLK_FREQ CLOCK_GetFreq(SYS_CLK)
/*******************************************************************************
* Variables
******************************************************************************/
uint8_t txbuff[] = "AT";
uint8_t rxbuff[100];
/*******************************************************************************
* Code
******************************************************************************/
/*!
* @brief Main function
*/
int main(void)
{
lpuart_config_t config;
BOARD_InitPins();
BOARD_BootClockRUN();
CLOCK_SetLpuart0Clock(0x1U);
BOARD_InitDebugConsole();
LPUART_GetDefaultConfig(&config);
config.baudRate_Bps = 9600;
config.enableTx = true;
config.enableRx = true;
LPUART_Init(DEMO_LPUART, &config, DEMO_LPUART_CLK_FREQ);
LPUART_WriteBlocking(DEMO_LPUART, txbuff, sizeof(txbuff) - 1);
LPUART_ReadBlocking(DEMO_LPUART, rxbuff, sizeof(rxbuff) - 1);
PRINTF("Response:\n");
PRINTF("%d\n", rxbuff);
}
But I am not getting any reply (even with "AT\r\n"), and any code after ReadBlocking does not read out.
Do I not also have to specify which pins I am using for RX/TX (PTB2/PTB1)? Not sure how to do that.
Thanks for any response, I am a complete newbie to this.
Hi,
It seems the code is copy from demo code. It should be ok. So I think the problem is on hardware connect or the detail of the communication protocol.
The pin config is in the BOARD_InitPins(). It use PB1 and PB2 as UART TX and RX.
regards,
Jing
Hi Jing,
I can see that the HM-10 is receiving the "AT" command by reading its output with an Arduino.
The problem now is the LPUART_ReadBlocking command. It cannot read rx. Hmmm. Not sure why.
Thanks for your help again