Reading USB registers directly on a Nordic nRF5340 DK

Hi everyone,

We are using the NCS 2.4.2 and the development board nRF5340 DK. We would like to read USB register as shown in the datasheet of this board (Attach this info), specifically REGISTER

And I have coded the following: 

/*
 * Copyright (c) 2018 Phytec Messtechnik GmbH
 *
 * SPDX-License-Identifier: Apache-2.0
 */


#include <logging/log.h>
#include <stdint.h>

LOG_MODULE_REGISTER(main);

// Define the USB peripheral base address
#define USB_BASE_ADDR 0x50037000

// Define USB register offsets
#define EVENTS_USBDETECTED_OFFSET 0x100

void main(void)
{
        volatile uint32_t *usb_base = (uint32_t *)USB_BASE_ADDR;

        // Read USB control register.
        uint32_t event_usb_detected = usb_base[EVENTS_USBDETECTED_OFFSET];

        if(event_usb_detected == 1){
          LOG_INF("USB EVENT detected");

        }

        // Do something with the register values.

        
}

With this error, titled as "missing expression":

C:\ncs\v1.7.0\toolchain\opt/bin/arm-none-eabi-gcc -DBUILD_VERSION=v2.6.99-ncs1 
-DEXT_API_MAGIC=0x281ee6de,0xb845acea,13570 -DFIRMWARE_INFO_MAGIC=0x281ee6de,0x8fcebb4c,13570 -DKERNEL 
-DNRF5340_XXAA_APPLICATION -DNRF_TRUSTZONE_NONSECURE -DUSE_PARTITION_MANAGER=1 -D_FORTIFY_SOURCE=2 
-D__PROGRAM_START -D__ZEPHYR__=1 -I../../../../../kernel/include -I../../../../../arch/arm/include 
-I../../../../../include -Izephyr/include/generated -I../../../../../soc/arm/nordic_nrf/nrf53 
-IC:/ncs/v1.7.0/nrf/include -IC:/ncs/v1.7.0/modules/hal/cmsis/CMSIS/Core/Include 
-IC:/ncs/v1.7.0/modules/hal/nordic/nrfx -IC:/ncs/v1.7.0/modules/hal/nordic/nrfx/drivers/include 
-IC:/ncs/v1.7.0/modules/hal/nordic/nrfx/mdk -I../../../../../modules/hal_nordic/nrfx/. -isystem 
../../../../../lib/libc/minimal/include -isystem 
c:/ncs/v1.7.0/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/include -isystem 
c:/ncs/v1.7.0/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/include-fixed -Os -imacros 
C:/ncs/v1.7.0/zephyr/samples/subsys/usb/hid/build_nrf5340dk_nrf5340_cpuapp_ns/zephyr/include/generated/autoconf.h 
-ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs 
-imacros C:/ncs/v1.7.0/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security 
-Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined 
-Wno-address-of-packed-member -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables 
-fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop 
-fmacro-prefix-map=C:/ncs/v1.7.0/zephyr/samples/subsys/usb/hid=CMAKE_SOURCE_DIR 
-fmacro-prefix-map=C:/ncs/v1.7.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/ncs/v1.7.0=WEST_TOPDIR 
-ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MF 
C:/ncs/v1.7.0/zephyr/samples/subsys/usb/hid/build_nrf5340dk_nrf5340_cpuapp_ns/zephyr\CMakeFiles\zephyr.dir\misc\generated\configs.c.obj.d 
-fno-diagnostics-show-caret -o zephyr/CMakeFiles/zephyr.dir/misc/generated/configs.c.obj -c zephyr/misc/generated/configs.c

Parents
  • Hi,

    You are building this through VS Code, correct?
    Could I see your prj.conf and the full build log?

  • #
    # Copyright (c) 2018 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    CONFIG_NCS_SAMPLES_DEFAULTS=y
    
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_NAME="Nordic_LBS"
    
    # Enable the LBS service
    CONFIG_BT_LBS=y
    CONFIG_BT_LBS_POLL_BUTTON=y
    CONFIG_DK_LIBRARY=y
    
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    CONFIG_GPIO=y

    At this moment, the project compiles properly but all the registers's values give me 0 (cero). I tried with all USBREG registers of the aforementioned picture.

    I checked this using debug tool and got the same results.

    My objective is to read the USB registers's values.

    Thanks in advanced.

Reply
  • #
    # Copyright (c) 2018 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    CONFIG_NCS_SAMPLES_DEFAULTS=y
    
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_NAME="Nordic_LBS"
    
    # Enable the LBS service
    CONFIG_BT_LBS=y
    CONFIG_BT_LBS_POLL_BUTTON=y
    CONFIG_DK_LIBRARY=y
    
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    CONFIG_GPIO=y

    At this moment, the project compiles properly but all the registers's values give me 0 (cero). I tried with all USBREG registers of the aforementioned picture.

    I checked this using debug tool and got the same results.

    My objective is to read the USB registers's values.

    Thanks in advanced.

Children
Related