nPM2100 interrupt not triggering with general timer

I am using the nPM2100 EK dev board with a stm32wl5MOC.

Using the example from the bare metal drivers, I adapted the code to my board.

I can succesfully read and set bytes on the i2c bus to the nPM2100.

Following the example, I am only using the timer part. I set the GPIO as such:

    rslt = gpio_npm2100_config(dev, PMIC_INT_OUT_PIN, NPM2100_GPIO_MODE_IRQ_LOW, NPM2100_GPIO_CONFIG_OUTPUT | NPM2100_GPIO_CONFIG_PULLUP);
where PMIC_INT_OUT_PIN = 1.
With an oscilloscope, I see the GPIO1 goes high after the timer setup function runs. After the 3sec interval has passed, I can see the timer status goes back to idle but the GPIO1 interrupt does not generate a low pulse. I have tried different combinations of GPIO modes and config, to no avail.
Here's the entire code:

#include "main.h"
#include "dma.h"
#include "i2c.h"
#include "app_lorawan.h"
#include "rtc.h"
#include "usart.h"
#include "gpio.h"
#include "stm32wl_utils.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "stm32_uart.h"
#include "LmHandler.h"
#include "lora_app.h"
#include "radio_board_if.h"
#include "sys_app.h"
#include "nPM2100.h"
#include "gpio_npm2100.h"

#define NPM2100_EVENT_SYS_TIMER_EXPIRY 2

#define PMIC_INT_OUT_PIN 1 // Set this to the correct pin number for your hardware

#define BIT(n) (1U << (n))

void SystemClock_Config(void);

void npm2100_ldo_setup(struct i2c_dev *dev);
void npm2100_TimerSetup(struct i2c_dev *dev, uint32_t period_ms);


int main(void)
{
    int8_t rslt = 0;
    
    HAL_Init();
    SystemClock_Config();
    MX_GPIO_Init();
    MX_DMA_Init();
    MX_USART2_UART_Init();
    MX_RTC_Init();
    MX_I2C1_Init();

    uint32_t events = 0;
    struct i2c_ctx npm2100_ctx;
    struct i2c_dev npm2100_dev = { .addr = 0x74, .context = &npm2100_ctx };
    uint8_t timer_reg = 0;
    i2c_init(&npm2100_dev, &hi2c1);

    HAL_Delay(100);
    rslt = nPM2100_Init(&npm2100_dev);
    if (rslt != 0) {
        printf("nPM2100 Init Error!\r\n");
    }
    else {
        printf("nPM2100 initialized successfully.\r\n");
    }
    

    HAL_Delay(100);

    npm2100_TimerSetup(&npm2100_dev, 3000);
    printf("nPM2100 timer set to 3 seconds.\r\n");

    rslt = nPM2100_StartTimer(&npm2100_dev);
    if (rslt != 0) {
        printf("nPM2100 start timer error: %d\r\n", rslt);
    }

    while (1){
        rslt = nPM2100_GetRegister(&npm2100_dev, 0xb7, &timer_reg);
        printf("timer status: 0x%02X\r\n", timer_reg);

        rslt = nPM2100_ProcessEvents(&npm2100_dev, &events);
        if (events & BIT(NPM2100_EVENT_SYS_TIMER_EXPIRY)) {
            rslt = nPM2100_StartTimer(&npm2100_dev);
            printf("nPM2100 timer expired, timer restarted.\r\n");
        }
        HAL_Delay(100);
    }
}

void npm2100_TimerSetup(struct i2c_dev *dev, uint32_t period_ms)
{
    int rslt;

    rslt = mfd_npm2100_stop_timer(dev);
    if (rslt != 0) {
        printf("nPM2100 stop timer error: %d\r\n", rslt);
    }

    HAL_Delay(3);

    rslt = mfd_npm2100_set_timer(dev, period_ms, NPM2100_TIMER_MODE_GENERAL_PURPOSE);
    if (rslt != 0) {
        printf("nPM2100 set timer error: %d\r\n", rslt);
    }

    rslt = mfd_npm2100_enable_events(dev, BIT(NPM2100_EVENT_SYS_TIMER_EXPIRY));
    if (rslt != 0) {
        printf("nPM2100 enable events error: %d\r\n", rslt);
    }

    rslt = gpio_npm2100_config(dev, PMIC_INT_OUT_PIN, NPM2100_GPIO_MODE_IRQ_LOW, NPM2100_GPIO_CONFIG_OUTPUT | NPM2100_GPIO_CONFIG_PULLUP);
    if (rslt != 0) {
        printf("nPM2100 GPIO config error: %d\r\n", rslt);
    }
}
Parents
  • Hi Charles,

    I don't see any issues in the setup function in your code. That seems to closely follow the example. I have also just checked your configuration (pull-up, active low interrupt) with Nordic development boards, and I do get low interrupt pulses on GPIO1 line.

    However, the definition of the `nPM2100_StartTimer` function doesn't seem to be included in your snippet. I would suspect something goes wrong there? Please check that function's implementation and share its source if you require further assistance.

    - Sergei

  • here's the implementation, which is exactly as in the repo's nrf version.

    Do you have any idea why I would not see the pulse probing the interrupt pin? The setup seems to be target agnostic, I don't understand why it would work on nrf and not on the stm since it's basic i2c commands.

    // from my api
    
    int nPM2100_StartTimer(struct i2c_dev *dev) {
    	return mfd_npm2100_start_timer(dev);
    }
    
    // from mfd_npm2100.c
    
    int mfd_npm2100_start_timer(struct i2c_dev *dev)
    {
    	return i2c_reg_write_byte(dev, TIMER_TASKS_START, 1U);
    }
Reply
  • here's the implementation, which is exactly as in the repo's nrf version.

    Do you have any idea why I would not see the pulse probing the interrupt pin? The setup seems to be target agnostic, I don't understand why it would work on nrf and not on the stm since it's basic i2c commands.

    // from my api
    
    int nPM2100_StartTimer(struct i2c_dev *dev) {
    	return mfd_npm2100_start_timer(dev);
    }
    
    // from mfd_npm2100.c
    
    int mfd_npm2100_start_timer(struct i2c_dev *dev)
    {
    	return i2c_reg_write_byte(dev, TIMER_TASKS_START, 1U);
    }
Children
Related