Skip to main content

GPIO Config and output failed issue

DA1469x

5 months ago

Posted by jerryjuan 225 points 4 replies
0 upvotes

we are using the sdk_10.0.10.118, and want to set the gpio output from active to inactive but fail.

Can you help me to check any configuration is missing?

 

        hw_gpio_set_pin_function(HW_GPIO_PORT_0, HW_GPIO_PIN_12, HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_GPIO);
        hw_gpio_configure_pin_power(HW_GPIO_PORT_0, HW_GPIO_PIN_12, HW_GPIO_POWER_V33);
        hw_gpio_configure_pin(HW_GPIO_PORT_0, HW_GPIO_PIN_12, HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_GPIO, true);

        hw_gpio_pad_latch_enable(HW_GPIO_PORT_0, HW_GPIO_PIN_12);

 

        OS_DELAY_MS(1000);
        hw_gpio_set_inactive(HW_GPIO_PORT_0, HW_GPIO_PIN_12);
        OS_DELAY_MS(1000);
        hw_gpio_set_active(HW_GPIO_PORT_0, HW_GPIO_PIN_12);
        OS_DELAY_MS(1000);
        hw_gpio_set_inactive(HW_GPIO_PORT_0, HW_GPIO_PIN_12);

 

 

5 months ago

jerryjuan 225 points

After set pin high/low, pin status is not changed accordingly, not sure what is going on.

5 months ago

PM_Dialog

Hi Jerry,

The P0_12 and P0_13 are the CMAC SWD.

Please see section 40.2.1 Programmable Pin Assignment and Table 146: Fixed Assignment of Specific Signals from the datasheet. See also Note 1 in page 299.

DA1469x datasheet : https://www.dialog-semiconductor.com/sites/default/files/2020-12/da1469x_datasheet_3v2.pdf

The CMAC Debugger is enabled by default – see dg_configENABLE_CMAC_DEBUGGER in bsb_debug.h.

So, in order to disable the CMAC Debugger and use P0_12 or P0_13 as GPIO, set the dg_configENABLE_CMAC_DEBUGGER to 0 in the custom configuration file (custom_config_XXX.h).

See below a code snippet for toggling the P0_12 and P0_13 in the periph_init().

In custom_config_XXX.h :

#define dg_configENABLE_CMAC_DEBUGGER           (0)

In periph_init():

hw_gpio_configure_pin(HW_GPIO_PORT_0, HW_GPIO_PIN_12, HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_GPIO, false);
hw_gpio_configure_pin(HW_GPIO_PORT_0, HW_GPIO_PIN_13, HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_GPIO, false);
hw_gpio_pad_latch_enable(HW_GPIO_PORT_0, HW_GPIO_PIN_12);
hw_gpio_pad_latch_enable(HW_GPIO_PORT_0, HW_GPIO_PIN_13);
hw_clk_delay_usec(100);
hw_gpio_set_active(HW_GPIO_PORT_0, HW_GPIO_PIN_12);
hw_gpio_set_active(HW_GPIO_PORT_0, HW_GPIO_PIN_13);
hw_clk_delay_usec(100);
hw_gpio_set_inactive(HW_GPIO_PORT_0, HW_GPIO_PIN_12);
hw_gpio_set_inactive(HW_GPIO_PORT_0, HW_GPIO_PIN_13);
hw_gpio_pad_latch_disable(HW_GPIO_PORT_0, HW_GPIO_PIN_12);
hw_gpio_pad_latch_disable(HW_GPIO_PORT_0, HW_GPIO_PIN_13);

Thanks, PM_Dialog

5 months ago

jerryjuan 225 points

HI PM_Dialog,

Thanks for your suggestion. I've already disable CMAC debugger before configure GPIO.
from your sample code, does it mean before I set GPIO to high, I need to enable latch ?
hw_gpio_pad_latch_enable()

And before I set it to low, I will need to disable latch? but I didn't see other GPIO setting doing this, is it necessary function I need to call it before I set any GPIO?

accepted answer!

5 months ago

PM_Dialog

Hi Jerry,

When latching a GPIO means that is activating the pad and connecting it to the digital logic.  When unlaching, it disconnects the pad from the digital logic and keeps the pad status. I am able to toggle the GPIO in the periph_init() with the code that you have provided. Where in the code you are trying to toggle the P0_12?

In order to use the CMAC debugger PADS as GPIOs you should :

1.       Disable the CMAC debugger as suggested in my previous reply

2.       Configure the PADs as GPIOS.

See below a sample code for toggling the P0_12:

hw_gpio_configure_pin(HW_GPIO_PORT_0, HW_GPIO_PIN_12, HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_GPIO, false);
hw_gpio_pad_latch_enable(HW_GPIO_PORT_0, HW_GPIO_PIN_12);
hw_clk_delay_usec(100);
hw_gpio_set_active(HW_GPIO_PORT_0, HW_GPIO_PIN_12);
hw_clk_delay_usec(100);
hw_gpio_set_inactive(HW_GPIO_PORT_0, HW_GPIO_PIN_12);
hw_gpio_pad_latch_disable(HW_GPIO_PORT_0, HW_GPIO_PIN_12);

Thanks, PM_Dialog