SPI not working with AFE4490 sensor

Hello community,

I have been recently working with AFE4490 sensor from protocentral (breakout board).

GitHub - Protocentral/protocentral-afe4490-arduino: Arduino Library for the AFE4490 SPO2 shield and breakout boards from Protocentral

Previously I have ported multiple sensors for my hobby projects and never faced any issue but I am not able to initialize the registers with this sensor in nrf52840.

Here are few things I trieD:

1. I evaluated this sensor with ESP32 C3 module and the sensor LED turns ON after succesful intialization.

2. Ported the C++ code base to nrf52840 SPI peripheral example code and description is mentioned below:

3. Used SPI pin as mentioned below:

4. Initialization routine for SPI is mentioned below:

nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
spi_config.miso_pin = AFE_MISO_PIN;
spi_config.mosi_pin = AFE_MOSI_PIN;
spi_config.sck_pin = AFE_SCK_PIN;
spi_config.ss_pin = AFE_CS_Pin;
spi_config.frequency = NRF_DRV_SPI_FREQ_8M;
APP_ERROR_CHECK(nrf_drv_spi_init(&afe_spi, &spi_config, afe_spi_event_handler, NULL));

nrf_gpio_cfg_output(AFE_MOSI_PIN);
nrf_gpio_cfg_output(AFE_SCK_PIN);
nrf_gpio_cfg_output(AFE_CS_Pin);

nrf_delay_ms(300);

Original working Arduino write function mentioned below:

m more focused on register initialiozation. Once its success then I will proceed further with reading of SPo2 and heart rate values. 

I am not sure where I am going wrong, I tried changing the modes to Mode 0,1,2,3 but nothing works. Its been a week now. Requesting somebody to help me on this.

Thank you.

Parents
  • Attached the C file FYR. Attaching the sensor image below:

    Requesting some guidance in the earliest.

    Thank you.

  • Two items to start with, worth fixing and retesting. The Arduino code uses SPI Mode 0 and 2MHz clock:

    At 8MHz and with a separate sensor board the nRF52 SPIM requires high-drive outputs (H0H1) on MOSI, SCK and CS. The default S0S1 may work at 2MHz, but will not be reliable unless the sensor is on the same board as the nRF52. Try these settings:

    nrfx style for setting port pins:

  • I got the code working (register initialization worked and I did see the sensor light turning ON) with these settings as attached in the code base. Can you please confirm if the read function that I ported is correct? or do i need to do any modifications for the same?

    Thanks in advance.

  • Did you just use the read function that hmolesworth uploaded here? I haven't tested it myself, so I can't confirm whether it's okay and I don't know how exactly you've set it up on your end. Nor do I know what modifications you might need, so please explain further what you mean here.

    Best regards,

    Simon

Reply
  • Did you just use the read function that hmolesworth uploaded here? I haven't tested it myself, so I can't confirm whether it's okay and I don't know how exactly you've set it up on your end. Nor do I know what modifications you might need, so please explain further what you mean here.

    Best regards,

    Simon

Children
No Data