This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

What Is "_Pos" << TIMER_BITMODE_BITMODE_Pos

Good evening,

The following link to "TIMER HAL" lists various enums, including for example "NRF_TIMER_BIT_WIDTH_32 (alias of) = TIMER_BITMODE_BITMODE_32Bit". I've used such enums several times, and the syntax seems quite self explanatory.

However, I've now come across for example "TIMER_BITMODE_BITMODE_32Bit << TIMER_BITMODE_BITMODE_Pos"

I realise that some variables are defined in files such as the nrf52840.h file, and that some things are documented in Nordic's Info Centre, and that other relevant info is elsewhere.

So, after a couple of hours searching for various search terms that include variations of "TIMER_BITMODE_BITMODE_Pos", I still haven't found any reference to it.

Therefore, please can someone kindly explain to me, in particular, what the "_Pos" part means? and does? and where I can find reference to it?

Thank you, Gary. 

  • Hi, 

    The values defined in nrf52_bitfields.h (under nRF5_SDK\modules\nrfx\mdk) follow a standard syntax: PERIPHERAL_REGISTER_FIELD_VALUE.

    In your example, TIMER_BITMODE_BITMODE_32Bit means that the peripheral is the TIMER, the register is BITMODE, the field is BITMODE and the value is 32BIT. 

    In addition to this, all fields have a _Pos definition, which gives you the bit position of this field within the register (for registers with multiple fields they will have different bit positions). 

    See Timer.BITMODE register documenataion.

    Regards,
    Amanda

  • Hi Amanda,

    So then I've now found the definition in the nrf52_bitfields.h file, which is great thank you.

    Just as an exercise for myself, I've followed your instructions... I first click on the register "BITMODE" at the top of the page, which takes me to the "BITMODE Address offset" table. Within that table I can see one field called "BITMODE" which has four possible values, 0, 1, 2, 3.

    Now then, on that particular page that you linked to, I have only noticed one field listed ("BITMODE") for the BITMODE register. 

    Final question is therefore... should ideally "TIMER_BITMODE_BITMODE_Pos" always be used, to set the bit position for the Timer Bitmode register Bitmode field? For example please visit the following page Measuring pulse time with timers/GPIOTE/PPI

    You'll see "NRF_TIMER4->BITMODE = TIMER_BITMODE_BITMODE_16Bit;", but that's all!

    Might it be just "good practice" to use "TIMER_BITMODE_BITMODE_Pos" in case additional fields exist in the future? or maybe "_Pos" sometimes gets applied automatically? ... and/or perhaps other fields for the BITMODE register are listed elsewhere?

    Thank you, Gary.

    Edit:

    Referring to the 2nd link in my opening post. I now have that program blinking an LED on my Nano 33 BLE, and indeed it still works after commenting "TIMER_BITMODE_BITMODE_Pos".

Related