This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Using GPIO 10 (NFC pin) to drive SPI SCLK

Good times,

So I finally put in the tweak to enable the GPIO 9&10 pins to be used for GPIO instead of the default NFC mode. Must remember that reset for it to take effect :-)

// Unlock the NFC pins as GPIO
uint32_t nfcpins = (*(uint32_t *)0x1000120C);
if (nfcpins & 1) {
    nrf_nvmc_write_word(0x1000120C, 0xFFFFFFFE);
    NVIC_SystemReset();
}

After this I wrote some code to toggle and create a square wave on the scope to show it was all working.

RMLOG("SPI Init\n MISO  %u\n MOSI  %u\n CLOCK %u\n CS    %u", ADXL_MISO_PIN, ADXL_MOSI_PIN, ADXL_SCK_PIN, ADXL_CS_PIN);
    
    RMLOG("Setting SCK high");
    
    nrf_gpio_cfg_output(ADXL_SCK_PIN);
    nrf_gpio_cfg_output(ADXL_MOSI_PIN);
    
    while (1) {
        nrf_gpio_pin_toggle(ADXL_SCK_PIN);
        nrf_gpio_pin_toggle(ADXL_MOSI_PIN);
        nrf_delay_ms(1);
    }

That all worked. I get a nice 3.2v (vdd) square wave.

Now I use the SPI to talk to a peripheral. Note that the SPI code works perfectly well on OTHER i/o pins on another board to the same chip without a problem.

On the board where I'm using the NFC GPIOs though it doesn't want to work.

When I scope the clock I see that its running 125khz (yay) which is the configured SPI clock rate but low and behold

It's 1.64v ... basically half VDD.

I can't understand why. Sounds like a resistor divider... something with the external sensor (ADXL362) when it's out of reset etc..? Don't know, don't see it performing like this on another board (well, I haven't measured but the other board just works and my SPI read/writes function.. this board no no..)

Any ideas?

Parents
  • It was fighting with the pin next to it (a small short had developed.. such fine pitch components) so after all these changes and trying on a fresh board there was no problem.

    But the useful snippet for getting it into GPIO mode properly is well worth leaving here and the reboot required especially as when you flash these things it's all reset.

  • HI , i have followed your above code to use the nfc pin as gpio , but am getting the following error.. main.c:43: undefined reference to `nrf_nvmc_write_word' am using the SDK v 13.0 and compiling it in the arm gcc compiler of linux terminal... can you please say , where am made a mistake...am a beginner to this platform, can you please guide me..

Reply
  • HI , i have followed your above code to use the nfc pin as gpio , but am getting the following error.. main.c:43: undefined reference to `nrf_nvmc_write_word' am using the SDK v 13.0 and compiling it in the arm gcc compiler of linux terminal... can you please say , where am made a mistake...am a beginner to this platform, can you please guide me..

Children
No Data
Related