Post Go back to editing

MISO pin internal pullup in SPI configuration

Thread Summary

The user asked how to activate the internal pull-up for the MISO pin in SPI configuration on MAX32xxx devices. The solution involves re-applying the pad configuration for MISO immediately after calling `MXC_SPI_Init()`, using `MXC_GPIO_FUNC_ALT1` and `MXC_GPIO_PAD_PULL_UP`. The user confirmed that this approach resolved the issue.
AI Generated Content
Category: Hardware
Product Number: MAX32655

Hi,

I would like to activate internal pullup of MISO pin in SPI configuration.

I used below before configuring SPI function as:

mxc_gpio_cfg_t miso_pin22;
    miso_pin22.port     = MXC_GPIO0;               // PORT0
    miso_pin22.mask     = MXC_GPIO_PIN_22;         // PIN0_22 (MISO)
    miso_pin22.func     = MXC_GPIO_FUNC_IN, ALT1 to ALT4;      // Changed here as IN, ALT1, ALT2, ALT3 and ALT4
    miso_pin22.pad      = MXC_GPIO_PAD_PULL_UP;    // 
    miso_pin22.vssel    = MXC_GPIO_VSSEL_VDDIOH;   // 3.3V I/O
    miso_pin22.drvstr   = MXC_GPIO_DRVSTR_0;       //
    MXC_GPIO_Config(&miso_pin22);                  // 
After of this, I configured the MCU as SPI function but pullup can not be activated.
How  can I activate an internal pullup of MISO pin?
Please advise.
  • Hi Satoru,

    On MAX32xxx devices, the weak and strong pull-ups are controlled within the GPIO pad block. Many of the SPI initialization helpers internally invoke MXC_GPIO_Config() for their pin mapping, which typically resets the pad configuration to its default state (i.e., no pull-up or pull-down). As a result, if a pull-up is configured prior to calling MXC_SPI_Init(), the driver will overwrite those pad settings.

    To address this, please proceed as follows:

    • Retain the MXC_SPI_Init() call as is.

    • Immediately after invoking it, apply a one-pin override for MISO in its SPI alternate function. Specifically, use MXC_GPIO_FUNC_ALT1 for SPI1_MISO on P0.22.

    // 1) Bring up SPI first
    MXC_SPI_Init(MXC_SPI0, 1, 0, 0, 0, /*... your args ...*/);
    
    // 2) Re-apply pad config for MISO in its ALT function
    mxc_gpio_cfg_t miso = {
        .port   = MXC_GPIO0,
        .mask   = MXC_GPIO_PIN_22,          // P0.22 = SPI1 MISO pin
        .func   = MXC_GPIO_FUNC_ALT1,       // the exact ALT for SPI1 MISO on P0.22
        .pad    = MXC_GPIO_PAD_PULL_UP,     // weak pull-up enabled
        .vssel  = MXC_GPIO_VSSEL_VDDIOH,    // if that pad is on the 3.3V bank
        .drvstr = MXC_GPIO_DRVSTR_0,
    };
    MXC_GPIO_Config(&miso);

    This approach remains robust even if you re-initialize SPI at a later point—simply re-apply the one-line override after each initialization.

    Kind regards,

    Haluk

  • Hi Haluk,

    Thank you for your advice. My MISO pin pullup worked as you suggested.

    Satoru

Before You Switch


Switching languages will make ADI Explorer unavailable. Resume your session by switching back to English and reopening ADI Explorer.