Microchip® Advanced Software Framework

Quick Start Guide for SYSTEM PINMUX - Basic

In this use case, the PINMUX module is configured for:

  • One pin in input mode, with pull-up enabled, connected to the GPIO module
  • Sampling mode of the pin changed to sample on demand

This use case sets up the PINMUX to configure a physical I/O pin set as an input with pull-up and changes the sampling mode of the pin to reduce power by only sampling the physical pin state when the user application attempts to read it.

Setup

Prerequisites

There are no special setup requirements for this use-case.

Code

Copy-paste the following setup code to your application:

struct system_pinmux_config config_pinmux;
config_pinmux.mux_position = SYSTEM_PINMUX_GPIO;
config_pinmux.direction = SYSTEM_PINMUX_PIN_DIR_INPUT;
config_pinmux.input_pull = SYSTEM_PINMUX_PIN_PULL_UP;
system_pinmux_pin_set_config(10, &config_pinmux);

Workflow

  1. Create a PINMUX module pin configuration struct, which can be filled out to adjust the configuration of a single port pin.
    struct system_pinmux_config config_pinmux;
  2. Initialize the pin configuration struct with the module's default values.
    Note
    This should always be performed before using the configuration struct to ensure that all values are initialized to known default settings.
  3. Adjust the configuration struct to request an input pin with pull-up connected to the GPIO peripheral.
    config_pinmux.mux_position = SYSTEM_PINMUX_GPIO;
    config_pinmux.direction = SYSTEM_PINMUX_PIN_DIR_INPUT;
    config_pinmux.input_pull = SYSTEM_PINMUX_PIN_PULL_UP;
  4. Configure GPIO10 with the initialized pin configuration struct, to enable the input sampler on the pin.
    system_pinmux_pin_set_config(10, &config_pinmux);

Use Case

Code

Copy-paste the following code to your user application:

Workflow

  1. Adjust the configuration of the pin to enable on-demand sampling mode.