This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

uart configuration putty?

Hi,

I am new to MCUs and I am trying to send information from NRF51 via UART (not BLE UART) to Putty. No matter what I try I can't seem to print anything on Putty. I started working with the template file under peripherals. The file produces no errors on keil.

I am using NRF_LOG_PRINTF statement. Here is the code:

    /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved.
 *
 * The information contained herein is property of Nordic Semiconductor ASA.
 * Terms and conditions of usage are described in detail in NORDIC
 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
 *
 * Licensees are granted free, non-transferable use of the information. NO
 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
 * the file.
 *
 */

/** @file
* @brief Example template project.
* @defgroup nrf_templates_example Example Template
*
*/
#include "RTE_Components.h"             // Component selection
#include <stdbool.h>
#include <stdint.h>
#include "nrf_adc.h"
#include "nrf.h"
#include "nrf_gpio.h"
#include "nordic_common.h"
#include "nrf_delay.h"
#include "app_error.h"
#include "app_timer.h"
#include "app_util_platform.h"
#include "boards.h"
#include "bsp.h"
#include "nrf_drv_adc.h"
#include "nrf_drv_config.h"
#include "nrf_log.h"
#include "nrf_drv_uart.h"
#include "nrf_drv_ppi.h"
#include "nrf_drv_timer.h"


//Main function
int main(void)
{
	uint32_t err_code;
	err_code = NRF_LOG_INIT();
	if (err_code != NRF_SUCCESS)
	{
			// Module initialization failed. Take corrective action.
	}
	NRF_LOG_PRINTF("Hello World \n");
}
/** @} */
Parents
  • you have to add a define in the preprocessor symbols.

    Add ENABLE_DEBUG_LOG_SUPPORT to Menu/project/options for target /c/c++/preprocessor symbols

    See app_trace.h

    Edit:

    preprocessor symbols are a basic programming construct, a little out of scope for this forum. Do a code search for ENABLE_DEBUG_LOG_SUPPORT and see what it does.

    BTW, You shouldn't need to init the uart manually

  • preprocessor symbols, are flags that are used when compiling the software to make some decisions, and some code is compiled or not because of the Symbols you select.

    This is the only thing you have on your main? which nRF are you using? You can try to initialize the UART like

    /**@brief  Function for initializing the UART module.
    
    
    */
    /**@snippet [UART Initialization] */
    
    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_Baud115200
        };
    
    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);
    

    }

    /**@snippet [UART Initialization] */
    

    then you should use printf to print what you want. Pay attention to the pins you configure and the Baudrate, because they need to match with your chip and your selected baudrate on Putty.

Reply
  • preprocessor symbols, are flags that are used when compiling the software to make some decisions, and some code is compiled or not because of the Symbols you select.

    This is the only thing you have on your main? which nRF are you using? You can try to initialize the UART like

    /**@brief  Function for initializing the UART module.
    
    
    */
    /**@snippet [UART Initialization] */
    
    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_Baud115200
        };
    
    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);
    

    }

    /**@snippet [UART Initialization] */
    

    then you should use printf to print what you want. Pay attention to the pins you configure and the Baudrate, because they need to match with your chip and your selected baudrate on Putty.

Children
No Data
Related