Gpio config input cause assertion & config missing dependencies

I use SDK v.2.6.1. To avoid other possible factors affecting the results, I only keep the simplest function in the code which is reading the potential of gpio every second and using log to display it on RTT. I have two questions and would like to ask. Thank you.

1. When setting p0.21 of gpio as input, the program will have an assertion error(as the follow fig). I have canceled qspi and i2c0 in the file .overlay.

At first I thought it was a bug in my program, so I modify the sample code zephyr/samples/basic/button and run it. But I soon discovered that this was not a problem with the code, because in the same code, when I set p0.27 as input rather than p0.21, the code could run normally(as the follow fig). I didn’t understand why! I knew that the comment CONFIG_ASSERT=y could Let the program run successfully, but this is not the result I want. How to make p0.21 an input pin?

2. In prj.conf, some configs will have missing dependencies. Will missing dependencies cause config settings fail?
(e.g. CONFIG_UART_CONSOLE was assigned the value y, but got the value n. Missing dependencies: SERIAL && SERIAL_HAS_DRIVER). If the setting fails, how to modify it to make the setting successful?

My prj.conf is as follows

CONFIG_GPIO=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_ASSERT=y
CONFIG_LOG=y

My .overlay is as follows

/ {
	zephyr,user {
		chrg_state-gpios = <&gpio0 21 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
	};
};

/delete-node/ &i2c0;

&qspi_default {
	group1 {
		psels = <NRF_PSEL(QSPI_SCK, 0, 19)>,
				<NRF_PSEL(QSPI_IO0, 0, 20)>,
				<NRF_PSEL(QSPI_IO2, 0, 22)>,
				<NRF_PSEL(QSPI_IO3, 0, 23)>,
				<NRF_PSEL(QSPI_CSN, 0, 17)>;
	};
};

&qspi_sleep {
	group1 {
		psels = <NRF_PSEL(QSPI_SCK, 0, 19)>,
				<NRF_PSEL(QSPI_IO0, 0, 20)>,
				<NRF_PSEL(QSPI_IO2, 0, 22)>,
				<NRF_PSEL(QSPI_IO3, 0, 23)>;
	};
};

My main program is as follows

#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/logging/log.h> 
LOG_MODULE_REGISTER(Custom_Board,LOG_LEVEL_DBG);

static int ret, bat_chrg_state;

#define SLEEP_TIME_MS   1000
#define zephyr_user_NODE DT_PATH(zephyr_user)
static const struct gpio_dt_spec chrg_state = GPIO_DT_SPEC_GET(zephyr_user_NODE, chrg_state_gpios); // chrg_state節點

int main(void)
{

	if (!gpio_is_ready_dt(&chrg_state)) {
		LOG_ERR("chrg_state is not ready");
		return 0;
	}

	ret = gpio_pin_configure_dt(&chrg_state, GPIO_INPUT);
	if (ret != 0) {
		LOG_ERR("Error %d: failed to configure %s pin %d\n",
			ret, chrg_state.port->name, chrg_state.pin);
		return 0;
	}

	for(;;){
		bat_chrg_state = gpio_pin_get_dt(&chrg_state);
		LOG_INF("bat_chrg_state:%d",bat_chrg_state);
		k_msleep(SLEEP_TIME_MS);
	}
}

  • Can you confirm that you are not able to detect the interrupts on the P0.21?

    I can detect the interrupts on the P0.21 when I comments the CONFIG_ASSERT=y.

    You are using a custom board, right? If so, then you don't need to make any changes. 

    Right. I see.

    So in that manner, yes, you have a custom board.

    Thank you. I understand.

    Try adding this to your .overlay file:

    I added, and when I build. There is an error happened.

    devicetree error: /aliases: undefined node label 'mx25r64'

    Here is my .overlay

    / {
    	zephyr,user {
    		chrg_state-gpios = <&gpio0 21 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>; // 27 work, 21 assertion
    	};
    };
    
    /delete-node/ &mx25r64;
    /delete-node/ &i2c0;

    And I try disabled qspi, but still error.

    &qspi {
    	status = "disabled";
    };
    

    And if that doesn't help, can you please take a picture of the device you are working on and upload it here?

    Sure. The following is the board I use.

    This is my code. I delete the PM. Now there is only P0.21 interrupt. I cance the comments of CONFIG_ASSERT=y in prj.conf.

    4657.button.zip

    By the way, I misunderstood the meaning of 'annotations' and 'comments'. 

    Sorry to trouble you all the time. 

    Best regards,

    Teson

  • Hello,

    So you have the Raytac equivalent of our DK. In that case, I suggest you try to build for that board, instead of our board. That means, create a new build configuration, and build for the board raytac_mdbt50q_db_40_nrf52840, and replace your nrf52840dk_nrf52840.overlay with raytac_mdbt50q_db_40_nrf52840.overlay, and remove the reference to mx25r64 (I also couldn't build, but I didn't dig into why it didn't work, since it is not present on your board). 

    Best regards,

    Edvin

  • Thank you very much. I finally can use the p0.21 as input without ASSERT when CONFIG_ASSERT=y.

    Best regards,

    Teson

  • Glad to hear that it worked!

    I'll close this ticket now. Open it if you have any related issues, or open a new ticket if you encounter any new issues. 

    Best of luck!

    Best regards,

    Edvin

Related