This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Problem using digital IO as MISO.

Hi, I'm trying to set P0.20 pin as MISO of my spi master to communicate with ADXL372 accelerometer sensor, but when the miso is disconnected the signal received matches with expected and when connected to the DK pin the signal is modified and results are different. 

The expected signal received when disconnected from DK: 

The received signal after connected to P0.20 pin:

I used the default configuration of SPI:

nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;

spi_config.frequency = NRF_DRV_SPI_FREQ_4M;
spi_config.ss_pin = SPI_SS_PIN; //P0.08;
spi_config.miso_pin = 20;
spi_config.mosi_pin = SPI_MOSI_PIN; //P0.16;
spi_config.sck_pin = SPI_SCK_PIN; //P0.16;
spi_config.mode = NRF_DRV_SPI_MODE_0;


uint32_t ret =nrf_drv_spi_init(&spi, &spi_config, NULL , NULL);

I've already tried to change the MISO pull config on sdk_config.h with no success.

NRFX_SPIM_MISO_PULL_CFG 1

I'm using SDK 15.2.0_9412b96 on PCA10040 V1.1.1 2016.35, with softdevice  s132 6.1.0.

Do you know how can I configure this pin to work properly? 

Parents Reply
  • Haakonsh thanks for your support!

    Actually I've also used the sensor and the nrf52 on our developed integrated board and the results were the same. I've accidentally discovered one solution, inserting some resistance(like 100 ohms) between the nrf pin and the sensor pin solved this strange behavior. Not sure why. 

    I've already used others sensors without this problem, so this must be something with this sensor. 

Children
  • That's strange how a 100ohm series resistor fixed the issue. 
    Anyways I'm glad you fixed your problem, SPI can be a real b**** to debug xD

  • from your oscilloscope traces it looks like the signal was ringing badly; adding a resistor into the signal line better matches the output pin impedence (which is low) to the input one (which is high). If you google 'signal line current limiting resistor' you'll see it's occasionally recommended although I've very rarely ever had to do it. We have a PPS timing box with a very sharp accurate pulse and accurate 50 ohms output, if you don't match the receiver to that at least fairly well, it rings like crazy. 100 ohms sounds quite high, usually 20 or so does the job, add too much and you start to drop your own signal voltage. 

Related