Hi, I have the following issue measuring my thermocouple output. I am able to measure temperatures above 30C with the thermocoiple shown above. When the temperature drop below 30C I am getting 7FFFFFh when reading the thermocouple output. RTD cold junction seems to work fine. I have the following settings:
Thermocouple: static const uint8_t adc_setup_TC[] = {0x40,0x03, 0x01,0x02,0x40,0x61};
RTD: static const uint8_t adc_setup_RTD[] = {0x40,0x03,0x13,0x00,0x40,0x51};
Excitation: static const uint8_t ADC_WR_SETUP_EXC[] = {0x4A,0x01,0x03,0x2F};
The excitation "ADC_WR_SETUP_EXC" is set once and never changes. I alternate between Thermocouple and RTD settings inside the infinite loop. I read data from the thermocouple 200 ms after I apply (0x40,0x03, 0x01,0x02,0x40,0x61) thermocouple settings. I do the same for the RTD.
spi_tx_buff_ptr = ADC_WR_SETUP_EXC; // Pointer set to ADC_WR_SETUP_EXC[] = {0x4A,0x01,0x03,0x2F}; buffer
// Reset rx buffer and transfer done flag
memset(m_rx_buf, 0, m_length_exc);
spi_xfer_done = false;
// Read internal registers into m_rx_buf
APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, (uint8_t const *)spi_tx_buff_ptr, length_read_reg, m_rx_buf, length_read_reg));
while (!spi_xfer_done)
{
__WFE();
}
for (;;){
nrf_gpio_pin_set(21); // Set Start high (START is 1)
nrf_delay_ms(1);
if ((cntr % 2) == 0){ //Every even count
//Initialize TC ADC
nrf_delay_ms(10);
spi_tx_buff_ptr = adc_setup_TC; //Initialize buffer pointer to the ADC1247 config: static uint8_t adc_setup_TC[] ={0x40,0x03,0x01,0x02,0x30,0x71};
memset(m_rx_buf, 0, length_rx_buf); // Reset rx buffer and transfer done flag
spi_xfer_done = false;
//Configure TC ADC via SPI transfer
APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, (uint8_t const *)spi_tx_buff_ptr, m_length_setup_tc, m_rx_buf, m_length_setup_tc));
while (!spi_xfer_done)
{
__WFE();
}
nrf_delay_ms(200);
//Read Thermocouple data
spi_tx_buff_ptr = adc_data;
memset(m_rx_buf, 0, length_rx_buf);// Reset rx buffer and transfer done flag
spi_xfer_done = false;
while(nrf_gpio_pin_read (23)){} //wait for !DRDY
//Read TC data via SPI
APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, (uint8_t const *)spi_tx_buff_ptr, m_length_adc_data, m_rx_buf, m_length_adc_data));
while (!spi_xfer_done)
{
__WFE();
}
TC[0] = m_rx_buf[0];
TC[1] = m_rx_buf[1];
TC[2] = m_rx_buf[2];
}
else{ //Every odd count
//Initialize RTD ADC
nrf_delay_ms(10);
spi_tx_buff_ptr = adc_setup_RTD; //Initialize buffer pointer to the ADC config: static uint8_t adc_setup_TC[] = {0x40,0x03,0x01,0x02,0x40,0x71};
// Reset rx buffer and transfer done flag
memset(m_rx_buf, 0, length_rx_buf);
spi_xfer_done = false;
//Configure TC ADC
APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, (uint8_t const *)spi_tx_buff_ptr, m_length_setup_rtd, m_rx_buf, m_length_setup_rtd));
while (!spi_xfer_done)
{
__WFE();
}
nrf_delay_ms(200);
//Read RTD data
spi_tx_buff_ptr = adc_data; //Initialize buffer pointer to the ADC data read: static const uint8_t adc_data[] = {0x00,0x00,0x00};
memset(m_rx_buf, 0, length_rx_buf);// Reset rx buffer and transfer done flag
while(nrf_gpio_pin_read (23)){} //wait for !DRDY
APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, (uint8_t const *)spi_tx_buff_ptr, m_length_adc_data, m_rx_buf, m_length_adc_data)); // Read TC data
while (!spi_xfer_done)
{
__WFE();
}
RTD[0] = m_rx_buf[0];
RTD[1] = m_rx_buf[1];
RTD[2] = m_rx_buf[2];
nrf_gpio_pin_clear(21); // Set Start Low (START is 0)
nrf_delay_ms(1);
// ADC is stopped
diff[0] = TC[0] + RTD[0];
diff[1] = TC[1] + RTD[1];
diff[2] = TC[2] + RTD[2];
LEDS_INVERT(BSP_LED_1_MASK);
nrf_delay_ms(200);
}
if (cntr <255)
cntr++;
else
cntr =0;
}
}
Need your help, thank you.