NRF52832 and GPIO #nrf52832 #gpio


forum.contas@...
 

Not sure if I'm going to have any help on this, but anyway:

I've a standard NRF52832 module that has connected to pin 5 a red LED.

If I flash the module (through JLink) with the Arduino framework, the led blinks without any problem. So there isn't a hardware issue.

Since the module is not a standard supported board, but it's a common supported processor, for using zephyr I've chose a similar board either the nrf52832_mdk or another that uses the same processor, created an overlay file to point the default LED to the correct pin and port (Port 0, pin 5), and flashed the blinky sample example.

It didn't work...

So I've checked several different based NRF52832 boards, checked that there was no pin conflicts on the DTS, only had enabled the CONFIG_GPIO=y on the prj.conf file, but nothing works. Flash it with the Arduino framework for the NRF, the link blinks.

Also flashing, for example the Zephyr BLE beacon example, works without any issue, so it seems I'm missing something crucial on the GPIO front.

I've tested with several different flags, like GPIO_OUTPUT, GPIO_OUTPUT_HIGH and so on, but nothing works.

So... any ideas of what I'm doing wrong, so that this simple GPIO is failing?


Erik Englund
 

Are you sure that your board boots correctly? ( debug through gdb or just simple serial output )

What version of the SDK are you using?
Is MCUBoot activated in your prj.conf?


forum.contas@...
 

Hi, No MCUBoot.

And yes, the board boots correctly and I can use GDB to debug.

I can see the GPIO driver calls, the values that are set and so on.

My prj.conf file is as simple as it can get: CONFIG_GPIO=y nothing else.

If I flash for example the BT beacon example, it works fine, so  not probably not an issue with the board. I've tried anything more complex, since I'm stuck with the simpler case :)

An example of the debug session:

84                      gpio_pin_set(gpio_dev, led->gpio_pin, 1);
(gdb) s
gpio_pin_set (port=port@entry=0x20000034 <__device_gpio_nrfx_p0>, pin=5 '\005', value=1) at 
/mnt/study/ZephyrRTOS/zephyrproject/zephyr/include/drivers/gpio.h:1005
1005            if (data->invert & (gpio_port_pins_t)BIT(pin)) {
(gdb) s
1006                    value = (value != 0) ? 0 : 1;
(gdb) s
1009            return gpio_pin_set_raw(port, pin, value);
(gdb) s
gpio_pin_set_raw (value=0, pin=<optimized out>, port=0x20000034 <__device_gpio_nrfx_p0>) at /mnt/study/ZephyrRTOS/zephyrproject/zephyr/include/drivers/gpio.h:1009
1009            return gpio_pin_set_raw(port, pin, value);
(gdb) s
z_impl_gpio_port_clear_bits_raw (pins=32, port=0x20000034 <__device_gpio_nrfx_p0>) at 
/mnt/study/ZephyrRTOS/zephyrproject/zephyr/include/drivers/gpio.h:784
784             return api->port_clear_bits_raw(port, pins);
(gdb) p port
$2 = (const struct device *) 0x20000034 <__device_gpio_nrfx_p0>
(gdb) p *port
$3 = {name = 0x3630 "GPIO_0", config = 0x360c <gpio_nrfx_p0_cfg>, api = 0x35e8 <gpio_nrfx_drv_api_funcs>, data = 0x200001bc <gpio_nrfx_p0_data>}
(gdb) p pins
$4 = 32
(gdb) s



Erik Englund
 

Have you done the initialization by running gpio_pin_configure with GPIO_OUTPUT_ACTIVE as third argument ?

Just to be clear, you´re trying to set pin p0.05 ? That´s located on chip pin7 (QFN48 pkg) ?
Chip pin 5 is routed to p0.03.

Med vänlig hälsning
Erik Englund

Innoware Development AB
Hyttvägen 13
73338 SALA

+46(0)707319440
Org.nr. 556790-2977
www.innoware.se


forum.contas@...
 

Ok, found the issue:

 It was do to pin mapping naming.  I was assuming that the pinmaps in Arduino D5, D6, and so on, corresponded to a direct GPIO map, so D5->GPIO_5 and so on... and that's not true.

 After using the correct pin number on Zephyr, it works as it should.