This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM263P4: AM263P4 PRU GPIO direction switching during runtime

Part Number: AM263P4
Other Parts Discussed in Thread: SYSCONFIG

Hi,

We are implementing a software-controlled serial bus master on the PRU, where the GPIO direction needs to change dynamically during a transaction (for example, switching from driving the data line to sampling it, similar to Quad SPI or other bidirectional protocols).

While looking through the documentation, I found the following register:

MSS_CTRL_PRU_ICSS_PRU0_GPIO_OUT_CTRL

The description appears to match exactly what we need:

"GPO output disable for ICSSM Port 0 IO. Disable output for using the pin as input."

I would like to clarify a few points:

  1. Is this the correct register for dynamically switching a PRU GPIO between output and input during runtime?
  2. Since this register resides in the MSS_CTRL/IOMUX block, does every runtime modification require unlocking and re-locking the MSS_CTRL KICK protection, or is there another recommended mechanism for frequent direction changes?
  3. Is this use case (changing GPIO direction during an active PRU communication) an intended use of this register, or is it primarily intended for one-time configuration generated by SysConfig?
  4. Is there any documented timing for this operation? In particular:
    • when does the output-enable change become effective relative to the register write?
    • is the change synchronized to the PRU clock?
    • is there any required delay before the firmware can safely switch from writing R30 to sampling R31?

Our goal is to implement a deterministic software bus controller entirely on the PRU, so understanding the timing and synchronization of GPIO direction changes is important.

Thank you.

  • Is this the correct register for dynamically switching a PRU GPIO between output and input during runtime?

    No its not supported on AM263Px,

    Its supported on AM261x only.

    • Since this register resides in the MSS_CTRL/IOMUX block, does every runtime modification require unlocking and re-locking the MSS_CTRL KICK protection, or is there another recommended mechanism for frequent direction changes?

    This is true for all RCM and MSS CTRL registers.

    Is this use case (changing GPIO direction during an active PRU communication) an intended use of this register, or is it primarily intended for one-time configuration generated by SysConfig?

    It is for one time configuration on AM263Px

    Is there any documented timing for this operation? In particular:
    • when does the output-enable change become effective relative to the register write?
    • is the change synchronized to the PRU clock?
    • is there any required delay before the firmware can safely switch from writing R30 to sampling R31?

    Currently we do not have this.

  • Thank you for your reply.

    However, I think my original question was different.

    I am not asking whether MCU+ SDK provides an API for this functionality. We are not using MCU+ SDK.

    Our question is whether the following sequence is the documented and supported way to change the PRU GPIO direction at runtime:

    1. Unlock MSS_CTRL using the KICK registers.
    2. Write MSS_CTRL_PRU_ICSS_PRU1_GPIO_OUT_CTRL.
    3. Lock MSS_CTRL again.

    We are already doing exactly this directly from the PRU, and it works correctly.

    What we would like to understand is whether this is the intended/supported programming model for the device, or whether there is another recommended mechanism for changing the GPIO direction at runtime.

    The TRM does not clearly state whether direct PRU writes to these MSS_CTRL registers are the expected way to perform this operation, so we would appreciate clarification.

  • What we would like to understand is whether this is the intended/supported programming model for the device, or whether there is another recommended mechanism for changing the GPIO direction at runtime.

    if the latency is acceptable and if this approach does not conflict with safety/security requirements of your application/software then it is fine.