How to control the GPIO P0.18 to output High and low with nrf52832?

background:

1: my board  is the same with the nRF52832-CIAA Reference Layout 1_0 from nordic docs.

2: the source code is from sample code: blinky_led

3: only change the led0 to led1

#define LED0_NODE DT_ALIAS(led0)
to
#define LED0_NODE DT_ALIAS(led1)

My question is that:

1: seems that the output reg is right (at least the reg value can be change with my control), but  the measured voltage is always 3.3V with multimeter.

2: whether below reg value can show all info about gpio P0.18 ?

the reg value is below when control high.

CNF[18] = 0X00000003

OUT = 0X00040060  // Here changed, bit 18 to 1

IN = 0X002001C0

DIR = 0X00040060

LATVCH = 0X0

DETECTMODE = 0X0

the reg value is below when control LOW.

CNF[18] = 0X00000003

OUT = 0X00000060   // Here changed,bit 18 to 0

IN = 0X002001C0

DIR = 0X00040060

LATVCH = 0X0

DETECTMODE = 0X0

  • I have upload the video to youtube. Please try this one, thanks a lot!

    www.youtube.com/watch?v=Qw8N2xWOhSE

    Yes , i can running the code. and find nothing excepion.

  • Hi,

    If you can write the information here in text that would be good, but looking at the video, it looks like it would be difficult to measure at the wrong point. I notice that you have an overlay file though. While I did not spot any issue when glancing at the video, the example works on the DK with toggling the P0.18 without any changes except the single line that you described in the initial post. So I reocmend you pelase revert all changes and test exactly that one, which I verified works on my end. If that does not work, perhaps you need to look at the soldering on your board. Could it be that you have been unlucky and that the pin is not soldered to the PCB so that there is no actual connection?

  • OK , i will do check the HW connect next.

    And do you see my sch ? is it ok? can the P0.18  floating ? and GPIO CNF[18]=3 (S0S1)?

    I guess that if GPIO CNF=3, do not need to PULL UP to 3.3V or PULL DOWN to GND with a RES.

    is correct that use the S0S1 for floating pin? 

  • Hi,

    Yes, there si no problem with the putput being floating. (A floating input is a problem, but then you can enable internal pull resistors).

    S0S1 means standard drive. For driving a LED direclty, you probably want high drive (or even consider using a buffer). But I sggest considering one thing a ta  time, and if you do not measure any changing voltage on the pin when it is set high or low that is not related to this (you could consider disconnecting it if you have it connected to a LED or anything else now to reduce the unknowns).

  • hi, Thanks for your support.  Can not control led should be have two reason:

    1: I confirm that P0.18 be short with VDD, so the output always high; when fixed hardware, it can work when debug mode.

    2: But It doesn't work when i use flash mode.( program the build output file to flash), i use the vscode + nrf connect develop environment.  I don't know this reason.  

    I guess that i have not program the bootloader or softdevice?  But when i click the flash button. just print:

    The program 'f:/projects/nrf/projects/blinky/build_og/zephyr/zephyr.elf' has exited with code 0 (0x00000000).

    No any tips for me to select other files to program.such as bootloader or softdiveice...etc.

    Could you help me for the second pointer. Thanks at first!

Related