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

Parents
  • Thanks for your reply.

    1:Sorry, the sample code name should be blinky,the path is ..\ncs\v2.7.0\zephyr\samples\basic\blinky

    2: The HW board is just from nRF52832-CIAA Reference Layout 1_0 from nordic docs. 

    3:  I just simple measure with VICTOR VC890D to mesure the voltage between P0.18 and GND.

    I dont know how to attach files here.

    So you mean all reg(CNF, OUT, IN, DIR, LATCH, DETECTMODE) related are list here. and no error obviously?

  • Hi,

    I see. Using the blinky sample, just changing from #define LED0_NODE DT_ALIAS(led0) to #define LED0_NODE DT_ALIAS(led1) is enough to ue P0.18 instead if you are building for the nRF52 DK as target board.

    Can you show how you build, sot hat I see which board you build for and verifyt hat you have nod modified the board fiels or added an overlay file (so that we know that led1 actually poitns to P0.18)? If that is OK, the next is to look at your hardware. Is there an issu ethere so that the poitn you are measuring on is not actually connected to P0.18?

  • 1: Could you tell me whether can attach files directly here?

    2: I upload some files in my qq zone, could you access these? 

    URL: https://user.qzone.qq.com/403417724/infocenter

    PCB is my self-define board( Just from the official  pcb file of chip package for Altium Designer tool) not  official nRF52 DK board.

    -> sch: my sch picutre

    -> pcb: my board pcb layout picture

    -> reg_P0.18_high is the debug screen-shot when set P0.18 to high in vscode

    -> reg_P0.18_low is the debug screen-shot when set P0.18 to low in vscode

    3: all GPIO are floatting

    4: no overlay files.

    5: prj.conf are below:

    CONFIG_GPIO=y
    CONFIG_SERIAL=y
    CONFIG_CONSOLE=y
    CONFIG_UART_CONSOLE=y
    CONFIG_PRINTK=y
  • Hi,

    1: Could you tell me whether can attach files directly here?

    You can either drag-and-drop the file right into the box where you are writing the reply, or you can use Insert -> Image/video/file.

    2: I upload some files in my qq zone, could you access these? 

    No, I am not ble to access it.

    PCB is my self-define board( Just from the official  pcb file of chip package for Altium Designer tool) not  official nRF52 DK board.

    Then we need to look at your board and verity that you are actually measuring on something that is physically connected to P0.18.

    How are you building the project? Are you building for nrf52dk_nrf52832 or another target?

    From what I see in the initial post you have been able to debug so that you know that the application is running, is that correct?

Reply
  • Hi,

    1: Could you tell me whether can attach files directly here?

    You can either drag-and-drop the file right into the box where you are writing the reply, or you can use Insert -> Image/video/file.

    2: I upload some files in my qq zone, could you access these? 

    No, I am not ble to access it.

    PCB is my self-define board( Just from the official  pcb file of chip package for Altium Designer tool) not  official nRF52 DK board.

    Then we need to look at your board and verity that you are actually measuring on something that is physically connected to P0.18.

    How are you building the project? Are you building for nrf52dk_nrf52832 or another target?

    From what I see in the initial post you have been able to debug so that you know that the application is running, is that correct?

Children
  • 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