[SOLVED] Accessing peripheral registers via the Console window commands

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] Accessing peripheral registers via the Console window commands

    Hello, from the Ozone user guide I could see that the CPU registers could be accessed via Target.GetReg(" ") from the console;
    On similiar grounds, what is the command to access the peripheral regsiter's value from the Console?
    Thank you.
    Images
    • TargetGetReg.png

      26.03 kB, 767×177, viewed 471 times
    • Ozone_PeripheralRegisters.png

      33.04 kB, 484×377, viewed 602 times
  • 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: 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 :)
    Images
    • TargetReg_2.png

      20.12 kB, 581×96, viewed 455 times

    The post was edited 1 time, last by skam ().

  • 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: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi Alex,
    unfortunately the proposed access via path didn't work. ("Peripherals/GPIO/GPIOA/ODR"). (pls see attachment)
    Thats why I had to try out the previosly mentioned method. Jfyi.

    Kind regards
    Images
    • TargetReg_PathAccess.png

      9.25 kB, 652×48, viewed 411 times
  • 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: segger.com/ticket/

    Or you can contact us via e-mail.