Hello all,
I am trying to do a simple task, yet I cannot manage to make it work. My goal is to use the GPIO 1.01 (defined as Digital I/O in the Data Sheet) as an output pin, set its logical value to High/Low and observe all changes in a Logic Analyzer.
The problem is that the pin stays always at High, no matter how many times I try to set it to Low.
Here is my implementation:
prj.conf
CONFIG_NCS_SAMPLES_DEFAULTS=y CONFIG_BT=y CONFIG_BT_PERIPHERAL=y CONFIG_BT_DEVICE_NAME="Nordic_LBS" # Enable the LBS service CONFIG_BT_LBS=y CONFIG_BT_LBS_POLL_BUTTON=y CONFIG_DK_LIBRARY=y CONFIG_SPI=y CONFIG_GPIO=y CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CMakeLists.txt
cmake_minimum_required(VERSION 3.13.1) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(NONE) target_sources(app PRIVATE src/main.c ) zephyr_library_include_directories(.)
Code snippet in main.c where I configure the pin and try to modify its value.
//Get GPIO_1 device struct device * trfEN; trfEN = device_get_binding("GPIO_1"); if(trfEN == NULL) { printk("Could not get trfEN device\n"); } else { printk("Found device trfEN\n"); } //Configure pin as output gpio_pin_configure(trfEN, 1, GPIO_OUTPUT_LOW); //Enable TRF by setting GPIO to HIGH int ret = gpio_pin_set(trfEN, 1, 1); //Set pin 1.01 to 1 if(ret != 0) { printk("Error setting pin to high\n"); } else { printk("Pin set to high successfully\n"); //This line is printed -> No error setting pin } //Try to set pin to low k_sleep(K_MSEC(1000)); ret = gpio_pin_set(trfEN, 1, 0); //Set pin 1.01 to 0 if(ret != 0) { printk("Error setting pin to high\n"); } else { printk("Pin set to high successfully\n"); //This line is printed -> No error setting pin }
I attach also the output that I see with a logic analyzer:
Any idea where I am doing something wrong?
Many thanks in advance!