[SOLVED] Accessing peripheral registers via the Console window commands

  • Hi Skam,
    I guess, Target.GetReg() should also work for peripheral registers. It might be that you need to specify the full "path" for your register, though, i.e. something like "Peripherals/GPIO/GPIOA/MODER". Could you please check if that works for you?
    Best regards
    -- AlexD

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

  • Hi Alex,
    thanks for your resplonse. Trying out your proposed soluation gave the idea to try out accessing the the peripheral reg like accessing a structure element.
    Taget.GetReg("Peripherals.GPIO.GPIOA.ODR"); //this works

    Attached you will find the console log.


    There is another way to access it, via Target.ReadU32(<peripheral_reg_address>); This works as well.
    Target.ReadU32(0x40020014);

    Thanks again.
    Kind regards

    PS: Just a small thought. Not very important though.
    For Target.GetReg() , the core has to be halted. Hence Debug.Halt(); would be needed beforehand.
    Perhaps it might be a good idea to implement Halt and Continue functions internal to GetReg(). This shall make the GetReg function much faster when these commands need to be automated.
    Thank you :)

  • Hi Skam,

    often there are multiple ways to achieve a desired effect. Since your peripheral registers are memory mapped they may be accessed like memory. That's why reading the memory location works as well.

    The script you create is less portable, though. While the same register may exist in another MCU it might reside at a different address. By using the path name in Target.GetReg() allows your script to execute fine on another MCU, while accessing the memory address may cause tedious update of cryptic hex numbers before making your script work properly on the new MCU,

    Best regards
    -- AlexD

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

  • Hi skam,
    actually, this should work. I guess, reason you did not see it working, might be that I specified "/" as a separator. Instead it should be ".", as you can see in the documentation of that command, which can be found in section 7.9.17.3 in the Ozone user's manual.
    Best regards
    -- AlexD

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!