Direct Hardware Register Access in Zephyre

Hello.. I want to access the nRF5340 registers to maniulate there values, for example : If, I want to acess the PSEL.RTS register or CONFIG of UART0  to initialize these. How may I have access of these to write any instruction like PSEL.RTS = 0x........; CONFIG = 0x.......;  Similarly how DIR , OUT or IN registers of PORT0 and PORT1 can be directly accessed in Zyphyre ?

Thanks

Parents Reply Children
  • Hi Susheel, I have gone through these files. How may I rename a GPIO pin for example : if I want to use Port0 pin 2 as led_pin, then may I define as :

    #define led-pin ...?

    or static const led_pin ..?

  • depends on how you are using led_pin? If you are using v1.8.0\nrf\lib\dk_buttons_and_leds\dk_buttons_and_leds.c library, then you should set the led pins in the device tree (zephyr\boards\arm\nrf5340dk_nrf5340\nrf5340_cpuapp_common.dts) for example "led0" node. This is set for the DK board of nRF5340 and if your board is different, then you should create board files for your own board.

    If you want to access directly the gpio, then use the API provided in modules\hal\nordic\nrfx\hal\nrf_gpio.h. for example if you want to toggle and led with gpio number 21, then you just use nrf_gpio_pin_toggle(21); It should be enough to just define is as below in this case

    #define led_pin 21

  • Dear,

    1. How to generate this pin constant:

    #define led_pin 21

    For example: let I want led on Pin 12 of P0, Button on Pin 30 of P1 .. then how will the pin constant to use above #define led ..., #define Button ... 

    2. I am using nRF5340DK kit. Does , the default internal Clock Nordic SOC starts automatically jut after power on or need some configuration ?

      

  • Hi Gulzar Singh,

    mexco said:
    For example: let I want led on Pin 12 of P0

    #define led_pin 12 
    #define button_pin (30 + 31)   // Since on port1.

    Note that nRF53 does only have 48 general purpose I/= pins so 30 on P1 is not a valid pin.

    mexco said:
    2. I am using nRF5340DK kit. Does , the default internal Clock Nordic SOC starts automatically jut after power on or need some configuration ?

    The clock sources can be configured and you can set them to be automatically started. there is a lot of info regarding that in devzone like here. Please search for those threads and see if you find them useful.

Related