nRF51 : Make the Printf to Work Well
2017-01-04 14:20
375 查看
You may encounter a problem that when you follow the standard UART(Universal Asynchronous Receiver/Transmitter) step, but the printf would not work well. the Standard UART code in Nordic example be (based on ):
You will find that the output be :
,instead of full "Start". It prints the first byte always.
To solve this insufficient it very knack but simple :
Your default including libraries should be like this :
Replace the components\libraries\uart\app_uart.c as components\libraries\uart\app_uart_fifo.c and components\libraries\fifo\app_fifo.c
And do not forget to add the corresponding including path ..\..\..\..\..\..\components\libraries\fifo and ..\..\..\..\..\..\components\libraries\uart
And now your printf would work well:
Replace the nrf
/**@brief Function for the Power manager. */ static void power_manage(void) { uint32_t err_code = sd_app_evt_wait(); APP_ERROR_CHECK(err_code); } #include "app_uart.h" #define UART_TX_BUF_SIZE (256) #define UART_RX_BUF_SIZE (256) /** * @brief UART events handler. */ void uart_events_handler(app_uart_evt_t * p_event) { switch (p_event->evt_type) { case APP_UART_DATA_READY: break; case APP_UART_COMMUNICATION_ERROR: APP_ERROR_HANDLER(p_event->data.error_communication); break; case APP_UART_FIFO_ERROR: APP_ERROR_HANDLER(p_event->data.error_code); break; case APP_UART_TX_EMPTY: break; case APP_UART_DATA: break; default: break; } } /** * @brief UART initialization. */ void uart_config(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_DISABLED, false, UART_BAUDRATE_BAUDRATE_Baud38400 }; APP_UART_FIFO_INIT(&comm_params, UART_RX_BUF_SIZE, UART_TX_BUF_SIZE, uart_events_handler, APP_IRQ_PRIORITY_LOW, err_code); APP_ERROR_CHECK(err_code); } /**@brief Function for application main entry. */ int main(void) { uint32_t err_code; bool erase_bonds; uart_config(); printf("Start...\r\n"); // Initialize.
You will find that the output be :
S
,instead of full "Start". It prints the first byte always.
To solve this insufficient it very knack but simple :
Your default including libraries should be like this :
Replace the components\libraries\uart\app_uart.c as components\libraries\uart\app_uart_fifo.c and components\libraries\fifo\app_fifo.c
And do not forget to add the corresponding including path ..\..\..\..\..\..\components\libraries\fifo and ..\..\..\..\..\..\components\libraries\uart
And now your printf would work well:
Start...
Replace the nrf
相关文章推荐
- To make the android emulator (AVD) work fine for ADT V22.2.1
- Data for the People: How to Make Our Post-Privacy Economy Work for You
- HOWTO:How to make the WebGrid work like an Excel sheet
- Busy to finish the work.
- How to run the Jar well?
- Spokesmen, How to make the Cosmetic legend(8)
- Hard work is the key to success
- Spokesmen, How to make the Cosmetic legend(6)
- Putting The One Minute Manager to Work
- Issue 12(Anyone can make things bigger and more complex. What require more effort and courage is to move in the opposite directi
- Spokesmen, How to make the Cosmetic legend(7)
- 在线平互动台活动启动《Discover How to Make the Computer Easier to Use with Windows Vista》
- The Full Guide To Make Portable Programs AIO
- Is it worth the effort to design software well?
- Spokesmen, How to make the Cosmetic legend(5)
- Introducation to Spring the farmework by Rod johnson
- the way to compart a long code line into parts in order to make the Horizontal scroll bar disappear in V.S' Text Editor
- Using the Java APIs for Bluetooth, Part 2 - Putting the Core APIs to Work
- how to `make` the src code of APUE book
- Failing To See the Big Picture - Mistakes we make when learning programming