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?