This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Disable GPIO_AS_PINRESET on NCS SDK

Hello everyone,

I'm working on an nrf52832 custom board and trying to initialize the SPI module(I configured pin 21 as SCK)

I known pin 21 is a PIN_RESET, so I set CONFIG_GPIO_AS_PINRESET=n, but it did not affect and my application not working.

What's I'm missing?

  • Hi,

     

    When you run a firmware that is configured with CONFIG_GPIO_AS_PINRESET=y, it will write to UICR. In order to erase UICR, you have to explicitly do so, or run a erase all (nrfjprog -e -f nrf52).

    Could you ensure that you have erased UICR first, then flash the new firmware?

     

    Kind regards,

    Håkon

  • Hi,

    It still not working. 

    Here are my SPI configurations and the custom board device tree:

    # LIS3DH Config
    CONFIG_SPI=y
    CONFIG_SPI_1=y
    CONFIG_SENSOR=y
    CONFIG_LIS2DH=y
    
    # GPIO config
    CONFIG_GPIO=y
    CONFIG_GPIO_AS_PINRESET=n

    &spi1 {
    	compatible = "nordic,nrf-spi";
    	/* Cannot be used together with i2c0. */
    	status = "okay";
    	sck-pin = <21>;
    	mosi-pin = <20>;
    	miso-pin = <19>;
    	cs-gpios = <&gpio0 18 GPIO_ACTIVE_LOW>;
    
    	lis2dh12: lis2dh12@0 {
    		compatible = "st,lis2dh", "st,lis2dh12";
    		reg = <0>;
    		spi-max-frequency = <10000000>;
    		irq-gpios =  <&gpio0 17 GPIO_ACTIVE_HIGH>;
    		label = "LIS2DH12-ACCEL";
    	};
    };

    const struct device *sensor = device_get_binding(DT_LABEL(DT_INST(0, st_lis2dh)));
    
    if (sensor == NULL) {
        LOG_INF("Could not get %s device\n", DT_LABEL(DT_INST(0, st_lis2dh)));
        return;
    }

    P/s: When I set CONFIG_SPI=n, my application ran, but I couldn't bind the sensor module and received Error log: Could not get LIS2DH12-ACCEL device.

    I set CONFIG_SPI=y again, the application didn't run anything.

  • Hi,

     

    Nhuan said:
    When I set CONFIG_SPI=n, my application ran, but I couldn't bind the sensor module and received Error log: Could not get LIS2DH12-ACCEL device.

    This makes sense, as you're using SPI as the transport layer towards your sensor.

     

    Nhuan said:
    I set CONFIG_SPI=y again, the application didn't run anything.

    What do you mean by not running anything? Is there a fault or similar occurring? Or no bus activity?

    Have you scoped the SPI lines? not just P0.21, but the others as well.

     

    Kind regards,

    Håkon

  • Hi, 

    I have some information log when my application starts running, and my BLE device will advertise.

    But, when I set CONFIG_SPI=y, I can't get any logs, and my device didn't advertise also.

    It seems like the program stuck somewhere

  • Hi,

     

    If there's no output, have you tried entering debug mode to see where its stuck?

     

    Kind regards,

    Håkon

Related