Hello everyone,
Testing on:
- nRF52DK (PCA 10040)
- SDK 13.0.0
I have been struggling with reading from the register of ADS1299. I just want to try to read info from ID register of this IC to make sure getting correctly data using SPI.
Below is my code to read the register, I couldn't receive correct the data which is supposed to get 0x1E. Could you help me to check whether something is wrong in this code?
Thank you!
uint8_t RREG_ADS(uint8_t address) { uint8_t data_reg; dataToSend[0] = address | 0x20; //Opcode 000n nnnn =0 : write n channels nrf_gpio_pin_clear(SPIM0_SS_PIN); // enable SS pin for ADS if(DEBUG){NRF_LOG_INFO("Read from DR register of ADS\r\n");NRF_LOG_FLUSH();} // Reset rx buffer and transfer done flag spi_xfer_done = false; memset(m_rx_buf,0,sizeof(m_rx_buf)); APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, dataToSend, 1, &data_reg, 1)); while (!spi_xfer_done){__WFE();} NRF_LOG_FLUSH(); if(DEBUG){NRF_LOG_INFO("Send 0x00\r\n");NRF_LOG_FLUSH();} spi_xfer_done = false; memset(m_rx_buf,0,sizeof(m_rx_buf)); APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, 0x00, 1, m_rx_buf, sizeof(m_rx_buf))); while (!spi_xfer_done){__WFE();} NRF_LOG_FLUSH(); nrf_gpio_pin_set(SPIM0_SS_PIN); // disable SS pin for ADS nrf_delay_us(15); return data_reg; }