GENMASK and FIELD_PREP macro can't get correct bits value of register

I use GENMASK and FIELD_PREP macro to get bits value of register. But it failed to get correct bits value.

  • Hello,

    What is the code you are referencing here?
    Please elaborate thoroughly on your issue.

    Best regards,
    Karl

  • Thanks for your reply! Do you think it is helpful if I share whole project source code about this issue?

  • snowuyl said:
    Thanks for your reply!

    No problem at all, we are happy to help!

    snowuyl said:
    Do you think it is helpful if I share whole project source code about this issue?

    No, I do not think so at this time.
    I am not familiar with the code you have shared in your ticket, but I see a reference to LP5861 which to my knowledge is a Texas Instrument LED driver. We only provide support for Nordic devices and code here on DevZone, and so if you require technical support with the driver for the LED driver chip you must reach out to Texas Instrument or whoever supplied the driver you are working with.

    Best regards,
    Karl

  • Thanks for your reply! This issue is not related to TI LED driver. This issue is related to I can’t get correct bit values from these two macros listed in ticket title. E.g. Register value is 0x5E and I would like to get value from bit 3 to bit 7 of register value.

  • snowuyl said:
    This issue is related to I can’t get correct bit values from these two macros listed in ticket title. E.g. Register value is 0x5E and I would like to get value from bit 3 to bit 7 of register value.

    I see. Where are these macros from?

    Best regards,
    Karl

1 2