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

GPIO Pin as INPUT in NRF5340

Hello ,

I am playing with PDK NRF 5340, I am trying to write a simple code to configure a PIN (0.10) which is not already in use by PDK.

When I print it's state it always says "LOW". here is my code.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <zephyr.h>
#include <sys/printk.h>
#include <device.h>
#include <drivers/gpio.h>
unsigned int status=1,old=1;
void main(void)
{
struct device* port0 = device_get_binding("GPIO_0");
int result=1;
result = gpio_pin_configure(port0, 10, GPIO_DIR_IN);
printk("Hello World! %s, %x \r\n", CONFIG_BOARD,result);
while (1)
{
gpio_pin_read(port0,10,&status);
if(old != status)
{
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

what my serial output says is - 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
*** Booting Zephyr OS build v2.1.99-ncs1 ***
Flash regionDomainPermissions
00 0x00000 0x08000 Securerwxl
01 0x08000 0x10000 Non-Securerwxl
02 0x10000 0x18000 Non-Securerwxl
03 0x18000 0x20000 Non-Securerwxl
04 0x20000 0x28000 Non-Securerwxl
05 0x28000 0x30000 Non-Securerwxl
06 0x30000 0x38000 Non-Securerwxl
07 0x38000 0x40000 Non-Securerwxl
08 0x40000 0x48000 Non-Securerwxl
09 0x48000 0x50000 Non-Securerwxl
10 0x50000 0x58000 Non-Securerwxl
11 0x58000 0x60000 Non-Securerwxl
12 0x60000 0x68000 Non-Securerwxl
13 0x68000 0x70000 Non-Securerwxl
14 0x70000 0x78000 Non-Securerwxl
15 0x78000 0x80000 Non-Securerwxl
16 0x80000 0x88000 Non-Securerwxl
17 0x88000 0x90000 Non-Securerwxl
18 0x90000 0x98000 Non-Securerwxl
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

and that's it It stays LOW no matter how I connect Pin 0.10 to GND or to 3.3v (vcc) from PDK itself.

I am using SES (nordic edition) v4.52

OS windows 7 64 bit

NCS_TAG is v1.2.0

Thanks and Regards