I have a laser distance sensor module. I want to connect this module with my nRF52 DK(PCA10040). The module communicates over UART:
-
Supply (2.8V-3.2V VDC) connected to VDD on the nRF52DK
-
Ground connected to GND on the nRF52DK
-
Tx connected to P0.06(Tx on DK)
-
Rx connected to P0.08(Rx on DK)
Communication from module:
- UART: 19200, 8N1
- Send command of "O":turn on the laser
- Send command of "C":turn off the laser
- Send command of "D":measure distance and return results
- Send command of "S":return module supply voltage
Here my Uart init:
static void uart_init(void)
{
uint32_t err_code;
const app_uart_comm_params_t comm_params =
{
RX_PIN_NUMBER,
TX_PIN_NUMBER,
RTS_PIN_NUMBER,
CTS_PIN_NUMBER,
APP_UART_FLOW_CONTROL_ENABLED,
false,
UART_BAUDRATE_BAUDRATE_Baud19200
};
APP_UART_FIFO_INIT( &comm_params,
UART_RX_BUF_SIZE,
UART_TX_BUF_SIZE,
uart_event_handle,
APP_IRQ_PRIORITY_LOW,
err_code);
APP_ERROR_CHECK(err_code);
}
If I have understood the example for Uart correctly, printf is for sending and uart_event_handle is the function for recieving.
Now if I do this:
printf("\r\nC\r\n");
On the Putty I will get a "C".
But when I measure the Tx(from nRF52DK to module) signals on the logic analyzer, I wont get 0x43(ASCII code for "C").
There will be 5 Bytes:
-
0xB0
-
0x50
-
0x92
-
0xB0
-
0x50
Why are there 5 Bytes? And why is there no 0x43?