Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRF52833 UART Application Compilation Error

Hello Everyone,

I am trying to bring-up the  UART  Application in NRF52833 Device.

 I have downloaded "nRF5_SDK_17.0.2_d674dde" file.

 Getting  below error, while compiling, 

error: unknown type name 'nrf_uarte_baudrate_t'
error: unknown type name 'nrf_uarte_error_mask_t'
error: unknown type name 'nrf_uarte_hwfc_t'
error: unknown type name 'nrf_uarte_parity_t'
unknown type name 'nrf_uarte_task_t'
error: unknown type name 'nrf_uarte_event_t'
error: 'NRF_UARTE_PSEL_DISCONNECTED' undeclared (first use in this function); did you mean 'NRF_UART_PSEL_DISCONNECTED'?
error: unknown type name 'nrf_uarte_baudrate_t'
error: unknown type name 'nrf_uarte_error_mask_t'
 error: unknown type name 'nrf_uarte_hwfc_t'
error: unknown type name 'nrf_uarte_parity_t'
error: unknown type name 'nrf_uarte_task_t'
error: unknown type name 'nrf_uarte_event_t'
error: 'NRF_UARTE_HWFC_DISABLED' undeclared (first use in this function); did you mean 'NRF_UART_HWFC_DISABLED'?
error: 'NRF_UARTE_HWFC_ENABLED' undeclared (first use in this function); did you mean 'NRF_UART_HWFC_ENABLED'?
error: 'NRF_UARTE_PARITY_INCLUDED' undeclared (first use in this function); did you mean 'NRF_UART_PARITY_INCLUDED'?
error: 'NRF_UARTE_PARITY_EXCLUDED' undeclared (first use in this function); did you mean 'NRF_UART_PARITY_EXCLUDED'?
error: 'NRF_UARTE_PSEL_DISCONNECTED' undeclared (first use in this function); did you mean 'NRF_UART_PSEL_DISCONNECTED'?
error: 'NRF_UARTE_HWFC_DISABLED' undeclared (first use in this function); did you mean 'NRF_UART_HWFC_DISABLED'?
error: 'NRF_UARTE_HWFC_ENABLED' undeclared (first use in this function); did you mean 'NRF_UART_HWFC_ENABLED'?
error: 'NRF_UARTE_PARITY_INCLUDED' undeclared (first use in this function); did you mean 'NRF_UART_PARITY_INCLUDED'?
error: 'NRF_UARTE_PARITY_EXCLUDED' undeclared (first use in this function); did you mean 'NRF_UART_PARITY_EXCLUDED'?

Below is my Uart.c sample Application,

#include "nordic_common.h"
#include "nrf.h"
#include "ble_hci.h"
#include "ble_advdata.h"
#include "ble_conn_params.h"
#include "nrf_sdh.h"
#include "nrf_sdh_soc.h"
#include "nrf_sdh_ble.h"
#include "nrf_ble_gatt.h"
#include "nrf_ble_qwr.h"
#include "app_timer.h"
#include "ble_nus.h"
#include "app_uart.h"
#include "app_util_platform.h"
#include "bsp_btn_ble.h"
#include "nrf_pwr_mgmt.h"
#include "mesh_app_utils.h"
#if defined (UART_PRESENT)
#include "nrf_uart.h"
#endif
#if defined (UARTE_PRESENT)
#include "nrf_uarte.h"
#endif
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"
#include "bsp.h"
#include "solus_uart.h"

#define APP_BLE_CONN_CFG_TAG            1                                           /**< A tag identifying the SoftDevice BLE configuration. */

#define DEVICE_NAME                     "Nordic_UART"                               /**< Name of device. Will be included in the advertising data. */
#define NUS_SERVICE_UUID_TYPE           BLE_UUID_TYPE_VENDOR_BEGIN                  /**< UUID type for the Nordic UART Service (vendor specific). */

#define APP_BLE_OBSERVER_PRIO           3                                           /**< Application's BLE observer priority. You shouldn't need to modify this value. */

#define APP_ADV_INTERVAL                800                                         /**< The advertising interval (in units of 0.625 ms. This value corresponds to 500 ms). */

#define APP_ADV_DURATION                BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED       /**< Disable advertising timeout. */

#define MIN_CONN_INTERVAL               MSEC_TO_UNITS(150,  UNIT_1_25_MS)           /**< Minimum acceptable connection interval. */
#define MAX_CONN_INTERVAL               MSEC_TO_UNITS(250,  UNIT_1_25_MS)           /**< Maximum acceptable connection interval. */
#define SLAVE_LATENCY                   0                                           /**< Slave latency. */
#define CONN_SUP_TIMEOUT                MSEC_TO_UNITS(4000, UNIT_10_MS)             /**< Connection supervisory timeout (4 seconds), Supervision Timeout uses 10 ms units. */
#define FIRST_CONN_PARAMS_UPDATE_DELAY  APP_TIMER_TICKS(5000)                       /**< Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (5 seconds). */
#define NEXT_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(30000)                      /**< Time between each call to sd_ble_gap_conn_param_update after the first call (30 seconds). */
#define MAX_CONN_PARAMS_UPDATE_COUNT    3                                           /**< Number of attempts before giving up the connection parameter negotiation. */

#define DEAD_BEEF                       0xDEADBEEF                                  /**< Value used as error code on stack dump, can be used to identify stack location on stack unwind. */

#define UART_TX_BUF_SIZE                256                                         /**< UART TX buffer size. */
#define UART_RX_BUF_SIZE                256                                         /**< UART RX buffer size. */

BLE_NUS_DEF(m_nus, NRF_SDH_BLE_TOTAL_LINK_COUNT);                                   /**< BLE NUS service instance. */
static uint16_t   m_conn_handle          = BLE_CONN_HANDLE_INVALID;                 /**< Handle of the current connection. */
static uint16_t   m_ble_nus_max_data_len = BLE_GATT_ATT_MTU_DEFAULT - 3;            /**< Maximum length of data (in bytes) that can be transmitted to the peer by the Nordic UART service module. */
static ble_uuid_t m_adv_uuids[]          =                                          /**< Universally unique service identifier. */
{
    {BLE_UUID_NUS_SERVICE, NUS_SERVICE_UUID_TYPE}
};

/**@brief   Function for handling app_uart events.
 *
 * @details This function will receive a single character from the app_uart module and append it to
 *          a string. The string will be be sent over BLE when the last character received was a
 *          'new line' '\n' (hex 0x0A) or if the string has reached the maximum data length.
 */
/**@snippet [Handling the data received over UART] */
void uart_event_handle(app_uart_evt_t * p_event)
{
    static uint8_t data_array[BLE_NUS_MAX_DATA_LEN];
    static uint8_t index = 0;
    uint32_t       err_code;

    switch (p_event->evt_type)
    {
        case APP_UART_DATA_READY:       
            UNUSED_VARIABLE(app_uart_get(&data_array[index]));
            index++;

            if ((data_array[index - 1] == '\n') ||
                (data_array[index - 1] == '\r') ||
                (index >= m_ble_nus_max_data_len))
            {
                if (index > 1)
            {
                NRF_LOG_DEBUG("Ready to send data over BLE NUS");
                NRF_LOG_HEXDUMP_DEBUG(data_array, index);

                do
                {
                    uint16_t length = (uint16_t)index;
                    err_code = ble_nus_data_send(&m_nus, data_array, &length, m_conn_handle);
                        if ((err_code != NRF_ERROR_INVALID_STATE) &&
                            (err_code != NRF_ERROR_RESOURCES) &&
                         (err_code != NRF_ERROR_NOT_FOUND) )
                    {
                        APP_ERROR_CHECK(err_code);
                    }
                    } while (err_code == NRF_ERROR_RESOURCES);
                }

                index = 0;
            }
            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;

        default:
            break;
    }
}
/**@snippet [Handling the data received over UART] */

/**@brief  Function for initializing the UART module.
 */
/**@snippet [UART Initialization] */
int solus_uart_init(void)
{
    uint32_t                     err_code;
    app_uart_comm_params_t const comm_params =
    {
        .rx_pin_no    = RX_PIN_NUMBER,
        .tx_pin_no    = TX_PIN_NUMBER,
        .rts_pin_no   = RTS_PIN_NUMBER,
        .cts_pin_no   = CTS_PIN_NUMBER,
        .flow_control = APP_UART_FLOW_CONTROL_DISABLED,
        .use_parity   = false,
#if defined (UART_PRESENT)
        .baud_rate    = NRF_UART_BAUDRATE_115200
#else
        .baud_rate    = NRF_UARTE_BAUDRATE_115200
#endif
    };

    APP_UART_FIFO_INIT(&comm_params,
                       UART_RX_BUF_SIZE,
                       UART_TX_BUF_SIZE,
                       uart_event_handle,
                       APP_IRQ_PRIORITY_LOWEST,
                       err_code);
    APP_ERROR_CHECK(err_code);
}
/**@snippet [UART Initialization] */

Can you please look into it and let me know what is causing this issue.

Thanks & Regards,
Haji

Parents
  • Hello,

    take a look into sdk_config.h: it seems that UART module is not enabled.

    Lot of code in Nordic library is masked by #ifdef / #endif, so maybe UART is disabled and its code is not compiled.

    bye

  • Uart is enabled in sdk_config.h, Please refer the below sdk_config.h file

    #ifndef NRFX_UART_ENABLED
    #define NRFX_UART_ENABLED 1
    #endif
    
    #ifndef NRFX_UART0_ENABLED
    #define NRFX_UART0_ENABLED 0
    #endif
    
    #ifndef NRFX_UART_DEFAULT_CONFIG_HWFC
    #define NRFX_UART_DEFAULT_CONFIG_HWFC 0
    #endif
    
    #ifndef NRFX_UART_DEFAULT_CONFIG_PARITY
    #define NRFX_UART_DEFAULT_CONFIG_PARITY 0
    #endif
    
    #ifndef NRFX_UART_DEFAULT_CONFIG_BAUDRATE
    #define NRFX_UART_DEFAULT_CONFIG_BAUDRATE 30924800
    #endif
    
    #ifndef NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY
    #define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 6
    #endif
    
    #ifndef NRFX_UART_CONFIG_LOG_ENABLED
    #define NRFX_UART_CONFIG_LOG_ENABLED 0
    #endif
    
    #ifndef NRFX_UART_CONFIG_LOG_LEVEL
    #define NRFX_UART_CONFIG_LOG_LEVEL 3
    #endif
    
    #ifndef NRFX_UART_CONFIG_INFO_COLOR
    #define NRFX_UART_CONFIG_INFO_COLOR 0
    #endif
    
    #ifndef NRFX_UART_CONFIG_DEBUG_COLOR
    #define NRFX_UART_CONFIG_DEBUG_COLOR 0
    #endif
    
    #ifndef UART_ENABLED
    #define UART_ENABLED 1
    #endif
    
    #ifndef UART_DEFAULT_CONFIG_HWFC
    #define UART_DEFAULT_CONFIG_HWFC 0
    #endif
    
    #ifndef UART_DEFAULT_CONFIG_PARITY
    #define UART_DEFAULT_CONFIG_PARITY 0
    #endif
    
    #ifndef UART_DEFAULT_CONFIG_BAUDRATE
    #define UART_DEFAULT_CONFIG_BAUDRATE 30801920
    #endif
    
    #ifndef UART_DEFAULT_CONFIG_IRQ_PRIORITY
    #define UART_DEFAULT_CONFIG_IRQ_PRIORITY 6
    #endif
    
    #ifndef UART_EASY_DMA_SUPPORT
    #define UART_EASY_DMA_SUPPORT 1
    #endif
    
    #ifndef UART_LEGACY_SUPPORT
    #define UART_LEGACY_SUPPORT 1
    #endif
    
    #ifndef UART0_ENABLED
    #define UART0_ENABLED 1
    #endif
    
    #ifndef UART0_CONFIG_USE_EASY_DMA
    #define UART0_CONFIG_USE_EASY_DMA 1
    #endif
    
    #ifndef APP_FIFO_ENABLED
    #define APP_FIFO_ENABLED 1
    #endif
    
    #ifndef APP_UART_ENABLED
    #define APP_UART_ENABLED 1
    #endif
    
    #ifndef APP_UART_DRIVER_INSTANCE
    #define APP_UART_DRIVER_INSTANCE 0
    #endif
    

Reply
  • Uart is enabled in sdk_config.h, Please refer the below sdk_config.h file

    #ifndef NRFX_UART_ENABLED
    #define NRFX_UART_ENABLED 1
    #endif
    
    #ifndef NRFX_UART0_ENABLED
    #define NRFX_UART0_ENABLED 0
    #endif
    
    #ifndef NRFX_UART_DEFAULT_CONFIG_HWFC
    #define NRFX_UART_DEFAULT_CONFIG_HWFC 0
    #endif
    
    #ifndef NRFX_UART_DEFAULT_CONFIG_PARITY
    #define NRFX_UART_DEFAULT_CONFIG_PARITY 0
    #endif
    
    #ifndef NRFX_UART_DEFAULT_CONFIG_BAUDRATE
    #define NRFX_UART_DEFAULT_CONFIG_BAUDRATE 30924800
    #endif
    
    #ifndef NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY
    #define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 6
    #endif
    
    #ifndef NRFX_UART_CONFIG_LOG_ENABLED
    #define NRFX_UART_CONFIG_LOG_ENABLED 0
    #endif
    
    #ifndef NRFX_UART_CONFIG_LOG_LEVEL
    #define NRFX_UART_CONFIG_LOG_LEVEL 3
    #endif
    
    #ifndef NRFX_UART_CONFIG_INFO_COLOR
    #define NRFX_UART_CONFIG_INFO_COLOR 0
    #endif
    
    #ifndef NRFX_UART_CONFIG_DEBUG_COLOR
    #define NRFX_UART_CONFIG_DEBUG_COLOR 0
    #endif
    
    #ifndef UART_ENABLED
    #define UART_ENABLED 1
    #endif
    
    #ifndef UART_DEFAULT_CONFIG_HWFC
    #define UART_DEFAULT_CONFIG_HWFC 0
    #endif
    
    #ifndef UART_DEFAULT_CONFIG_PARITY
    #define UART_DEFAULT_CONFIG_PARITY 0
    #endif
    
    #ifndef UART_DEFAULT_CONFIG_BAUDRATE
    #define UART_DEFAULT_CONFIG_BAUDRATE 30801920
    #endif
    
    #ifndef UART_DEFAULT_CONFIG_IRQ_PRIORITY
    #define UART_DEFAULT_CONFIG_IRQ_PRIORITY 6
    #endif
    
    #ifndef UART_EASY_DMA_SUPPORT
    #define UART_EASY_DMA_SUPPORT 1
    #endif
    
    #ifndef UART_LEGACY_SUPPORT
    #define UART_LEGACY_SUPPORT 1
    #endif
    
    #ifndef UART0_ENABLED
    #define UART0_ENABLED 1
    #endif
    
    #ifndef UART0_CONFIG_USE_EASY_DMA
    #define UART0_CONFIG_USE_EASY_DMA 1
    #endif
    
    #ifndef APP_FIFO_ENABLED
    #define APP_FIFO_ENABLED 1
    #endif
    
    #ifndef APP_UART_ENABLED
    #define APP_UART_ENABLED 1
    #endif
    
    #ifndef APP_UART_DRIVER_INSTANCE
    #define APP_UART_DRIVER_INSTANCE 0
    #endif
    

Children
  • I suggest to search in the whole project where are 

    error: unknown type name 'nrf_uarte_baudrate_t'
    error: unknown type name 'nrf_uarte_error_mask_t'
    error: unknown type name 'nrf_uarte_hwfc_t'
    error: unknown type name 'nrf_uarte_parity_t'

    those types defined. I'm pretty sure that you will find that that code is masked from compilation

  • Hello Haji,

    This is indeed a good suggestion by StefXinet - checking your project for these particular types and defines, to see if they are found by your IDE.

    Could you confirm that you have added the path to the header files into the User Included Directories section of the Preprocessor tab, when you view the Project Options in Common Configuration?

    Haji said:
    Please refer the below sdk_config.h file

    The reason might be that you have included both the NRFX_*_ENABLED and the legacy *_ENABLED in your sdk_config.h file.
    Please only use one of them, and please make sure that the one not selected is removed from the sdk_config entirely (i.e you may not just define UART_ENABLED to 0, you need to comment it out or remove it all together).
    This is caused by the apply_old_config.h file which overwrites your NRFX_*_ENABLED defines if the legacy *_ENABLED is left defined.
    This behavior is known to cause some confusion. The existence of the apply_old_config is to ensure backwards compatibility when migrating older projects to newer SDK's. You can read more about this issue here

    Please do this, and let me know if it resolves your issue.

    Best regards,
    Karl

    P.s I also notice that you have defined NRFX_UART0_ENABLED to 0 - if you intend to use the UART0 instance, this needs to be defined as 1.

Related