i was using the serial example in examples/peripheral/serial and i Want to display integer value int i=1234 on the serial terminal(putty).I want to convert the int value to string.
i was using the serial example in examples/peripheral/serial and i Want to display integer value int i=1234 on the serial terminal(putty).I want to convert the int value to string.
if i use it in the serial program it is not working.
.
int main(void) { ret_code_t ret; ret_code_t ret1; ret = nrf_drv_clock_init(); APP_ERROR_CHECK(ret); ret = nrf_drv_power_init(NULL); APP_ERROR_CHECK(ret); nrf_drv_clock_lfclk_request(NULL); ret = app_timer_init(); APP_ERROR_CHECK(ret); bsp_board_leds_init(); bsp_board_buttons_init(); ret = nrf_serial_init(&serial_uart, &m_uart0_drv_config, &serial_config); APP_ERROR_CHECK(ret); char *tx_message ; int i = 12345; tx_message = change(i); ret = nrf_serial_write(&serial_uart, tx_message, strlen(tx_message), NULL, NRF_SERIAL_MAX_TIMEOUT); printf("%d",i); APP_ERROR_CHECK(ret); while (true) { /* char c; ret = nrf_serial_read(&serial_uart, &c, sizeof(c), NULL, 1000); if (ret != NRF_SUCCESS) { continue; } (void)nrf_serial_write(&serial_uart, &c, sizeof(c), NULL, 0); (void)nrf_serial_flush(&serial_uart, 0); */ ret = nrf_serial_write(&serial_uart, tx_message, strlen(tx_message), NULL, NRF_SERIAL_MAX_TIMEOUT); // printf("%d",i); ret = nrf_serial_write(&serial_uart, "\n\r", strlen(tx_message), NULL, NRF_SERIAL_MAX_TIMEOUT); (void)nrf_serial_flush(&serial_uart, 0); nrf_delay_ms(2000); APP_ERROR_CHECK(ret); } }
which sdk version you are using?
sdk 14.2.0
it is working perfectly fine..i have checked it..