LPC

Sample List

This chapter introduces the details of the LPC sample code. The RTL87x2G provides the following samples for the LPC peripheral.

Functional Overview

The Low Power Comparator (LPC) compares the input voltage with the reference voltage. The output of the LPC can be monitored by the CPU and can trigger interrupts on a rising edge or high level. In addition, LPC supports the DLPS wake-up function.

Feature List

  • 8 external channels.

  • 1 internal channel.

  • Supports configurable high/low threshold voltage interrupt trigger.

  • Support DLPS wake-up.

Channels

LPC supports 8 external comparison channels and one internal comparison channel. Configure LPC comparison channels during initialization via LPC_InitTypeDef::LPC_Channel.

  • 8 external channels: LPC_CHANNEL_ADC0 ~ LPC_CHANNEL_ADC7 correspond to pins P2_0, P2_1, P2_2, P2_3, P2_4, P2_5, P2_6, and P2_7 respectively.

  • 1 internal channel: LPC_CHANNEL_VBAT.

Debounce

LPC supports an 8-bit debounce counter, utilizing a 32kHz clock for debounce functionality.

Enable debounce functionality by setting LPC_InitTypeDef::LPC_DebouncEn to ENABLE, set the debounce clock division factor via LPC_InitTypeDef::LPC_DebouncDiv, and set debounce time via LPC_InitTypeDef::LPC_DebouncCnt. Debounce time = (debounce count + 1) * debounce_period.

DLPS Wake-up

The system can be awakened from DLPS state when LPC comparison meets the conditions. Call LPC_WKCmd() function to set LPC wake-up functionality.