Blog

PORT Peripheral in S32K144

PORT Introduction

–> The Port Control and Interrupt (PORT) module supports port control, digital filtering, and external interrupt functionalities. It allows configuration for each pin in a 32-bit port independently of its pin muxing state. Each port has one instance of the PORT module, though not all pins may be implemented on every device.

–> Before going through technical details, let’s have a crisp gist of a what exactly PORT peripheral is. PORT peripheral is a role assigner through which we assign parameters to the pins of the microcontroller. Through parameters, we are referring to the peripheral functionality of pins. Each pin has its unique mathematically calculated value called PCR value. Using this PCR value(unique name), we tell PORT peripheral what properties are to be assigned to those pins. These properties or features can be understood in the “Features of PORT” section in detail but the most important property is assigning the mode of operation for a pin.

Features of PORT

–> The PORT module provides a range of features for pins, but these are grouped into major 3 features which are pin interrupt, digital input filter, and port control. Let’s understand each portion one by one, talking about the pin interrupt and digital input filter, we can take a gist about these two topics because these two topics are not major use of usual programming but knowledge is important about everything. First is pin interrupt, which is quite self-explanatory in that this feature provides an interrupt facility to each of the configurable pins for generating interrupt. talking about interrupt is a great concept for learning which can be learned from this blog, but rather than diverting somewhere else, I’ll brief you about interrupt. interrupt is a signal which can halt the current execution for some more prior work. you can take it as if you are enjoying your day seamlessly and suddenly your exam date sheet drops, then that’ll be an interrupt that shifts your focus from current work to more prior work. similarly, you can also create an interrupt for pins that are to be configured. Now, moving toward the digital input filter, this concept might be too overwhelming but I’ll try to brief you so that nothing leaves your keen learning of the PORT module. Let’s say you have a stable HIGH logic at the input pin, now you have you first enable the digital input filter and then load a Filter Length Value which is a kind of delay time. Now this Filter Length defines how long the input signal must driven LOW before the MCU can detect the falling edge. pulses that are shorter than this value will be absorbed and not acknowledged by MCU. there are more constraints behind this filter length but now you have enough knowledge about what a digital input filter does. At last, we come to our main focus which is PORT CONTROL. Port Control as it clarifies its name this feature help in controlling the PORT and its pins. first and one of the most used features of the port control is pin multiplexing. Pin multiplexing is used to enable a specific peripheral functionality of a pin. A single microcontroller pin can used more than one peripheral but a pin can only be used a single peripheral pin at a time. after pin multiplexing, we are gonna talk about the 

Functional Explanation of PORT

1. Pin Control

–> Each port pin has a corresponding Pin Control Register, PORT_PCRn, which manages both interrupt/DMA request settings and specific pin functions within the 32-bit port. The upper half of PORT_PCRn configures interrupt or DMA request settings, allowing triggers on rising, falling, or both edges, along with an interrupt flag. The lower half controls pullup/pulldown resistors, drive strength, passive input filter enable, and Pin Muxing mode selection. Pin configurations in the register remain active even when the PORT module is disabled.

–> Pin muxing mode overrides all digital functions (including pullup/pulldown resistors and buffer enable) when set to analog or disabled, lowering power consumption. The LK bit in PORT_PCRn locks pin configuration until the next system reset. When using digital modes, input buffers are enabled, allowing pin states to be read through GPIO_PDIR(GPIO Port Data Input Register). Floating pins can increase power consumption and should be grounded with an internal or external pull resistor.

2. Global Pin Control

–> The global pin control registers enable quick configuration of up to 16 pins with a single write operation, applying the same value to the lower half of each pin control register in the selected port. This feature is useful for setting multiple pins for the same peripheral function efficiently, though it cannot configure interrupt functions. Registers locked individually cannot be modified via the global pin control registers. These registers are write-only and return 0 when read.

3. Global Interrupt Control

–> The global interrupt control registers allow efficient configuration of the upper half of the pin control registers for up to 16 pins in a port with a single write, applying the same interrupt settings to each selected pin. They enable streamlined setup for consistent interrupt configurations across multiple pins but cannot be used to configure other pin control functions. These registers are write-only and return 0 when read.

4. External interrupts

–> The PORT module’s external interrupt capability is available in all digital pin muxing modes when enabled. Each pin can be individually configured for various interrupt modes, including:

    • Interrupt disabled (default on reset)
    • Level-sensitive interrupt: Active high or active low
    • Edge-sensitive interrupt: Rising, falling, or both edges
    • DMA requests: Rising, falling, or both edge sensitivity

–> When the configured edge or level is detected (filtered if digital input filter is enabled), the interrupt status flag is set. In normal modes, the input synchronizes with the bus clock for detection.

–> The PORT generates a single interrupt when any enabled interrupt flag is set, and it clears when all flags are cleared by writing 1 to the ISF flag in PORT_ISFR or PORT_PCRn. Similarly, a single DMA request asserts when an interrupt status flag for an enabled DMA request is set and negates once the DMA transfer completes.

–> In Stop mode, an enabled interrupt’s status flag is set asynchronously if the required edge or level is detected, generating a wake-up signal to exit Low-Power mode.

5. Digital Filter

–> The digital filter in the PORT module operates in all digital pin muxing modes when the PORT module is enabled. Key points:

    • Clock Source: Configurable between bus clock or LPO clock for each port. If using the bus clock, digital filters are bypassed during Stop mode, where filter outputs match input pins, but filter states remain static.
    • Filter Width: Uniform for all digital filters on a port and adjustable only when all filters on that port are disabled.
    • Operation: Filter output starts as logic zero after reset or when disabled. Once enabled, the input synchronizes with the filter clock. If the input remains stable for the configured filter width, the filter output updates to match it.

–> The maximum latency for a filter output update is three clock cycles plus the configured filter width.

Rohan Singhal
Author: Rohan Singhal

Author

Rohan Singhal

Leave a comment

Stay Updated With Us

Error: Contact form not found.

      Blog