I'm working on an application with SD card, and I've noticed what I think is strange behavior on MOSI. SD has pullup on every pin (10k), per the spec. Whichever pin I choose as MOSI floats to around 1.7V on SPI initialization, and can't pull the signal high or low after that. At first I thought maybe it was my hardware, but then I accidentally messed up which pin I was using and saw the same behavior on the CLK line when I accidentally chose it as MOSI. I'm using the nRF52840-DK and an SD card (actually a micro SD card) module that I can move around the board. I've tried a wide variety of pins and they all show the same behavior. Tried it with a card in the reader or no card in the reader, same behavior. I checked the pins on the SD module and they all show the right resistance values. All other pins pull high or low accordingly, as expected, regardless of what pins I choose. I suspect I'm doing something silly, but I can't imagine what it is... Is there some pulldown value on the line selected on MOSI? I suspect no since the pin also can't drive a signal, but I'm not sure what else to look at and I see no errata. Is 10k pullup too low or something?
Here's some code (SDK 17.0.2) for completeness:
... const nrfx_spim_t m_spim3 = NRFX_SPIM_INSTANCE(3); ... int main() { nrfx_spim_config_t spim_cfg = NRFX_SPIM_DEFAULT_CONFIG; ret_code_t error; nrfx_spim_xfer_desc_t desc; uint8_t tx_buff[6]; uint8_t rx_buff[8]; spim_cfg.frequency = NRF_SPIM_FREQ_1M; spim_cfg.ss_pin = NRF_GPIO_PIN_MAP(1, 04); spim_cfg.sck_pin = NRF_GPIO_PIN_MAP(1, 02); spim_cfg.mosi_pin = NRF_GPIO_PIN_MAP(1, 03); spim_cfg.miso_pin = NRF_GPIO_PIN_MAP(1, 01); spim_cfg.mode = NRF_SPIM_MODE_0; spim_cfg.use_hw_ss = true; error = nrfx_spim_init(&m_spim3, &spim_cfg, NULL, NULL); APP_ERROR_CHECK(error); // SD CMD0 tx_buff[0] = 0x40; tx_buff[1] = 0x00; tx_buff[2] = 0x00; tx_buff[3] = 0x00; tx_buff[4] = 0x00; tx_buff[5] = 0x95; desc.p_tx_buffer = tx_buff; desc.tx_length = 6; desc.p_rx_buffer = rx_buff; desc.rx_length = 8; nrfx_spim_xfer(&m_spim3, &desc, 0); // Enter main loop. for (;;) { idle_state_handle(); } }