This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

F28377D-SEP: Issue Printing Floating-Point Values on F28379D (Program Hangs When Using %f)

Part Number: F28377D-SEP
Other Parts Discussed in Thread: ADS8638

Hi,

I am currently using the TI F28379D board interfaced with the ADS8638 ADC.
I am able to read ADC data correctly and print integer values using uart_printf.

However, when I modify the code to use floating-point calculations and print values using the %f format specifier, the program gets stuck and stops executing.

Working Code (Integer-Based – Works Correctly)

void ads8638_raw_to_voltage(uint16_t raw)
{
    uint8_t channel = (raw >> 12) & 0x07;
    uint16_t adc_raw = raw & 0x0FFF;

    int32_t mv_at_adc_pin = 0;
    int32_t final_hw_voltage = 0;

    const float HW_GAIN_FACTOR = 5.0f;

    if (channel == 2 || channel == 3)
    {
        int16_t signed_val;

        uart_printf("CH%u [BIPOLAR] Raw: 0x%03X | ", channel, adc_raw);

        if (adc_raw & 0x800)
        {
            signed_val = (int16_t)(adc_raw | 0xF000);
            uart_printf("SIGN: NEG | ");
        }
        else
        {
            signed_val = (int16_t)adc_raw;
            uart_printf("SIGN: POS | ");
        }

        mv_at_adc_pin = ((int32_t)signed_val * 10000) / 2048;
        final_hw_voltage = (int32_t)((float)mv_at_adc_pin * HW_GAIN_FACTOR);

        uart_printf("Pin_mV: %ld | HW_Voltage: %ld mV\r\n",
                    mv_at_adc_pin, final_hw_voltage);
    }
    else
    {
        mv_at_adc_pin = ((int32_t)adc_raw * 10000) / 4095;
        uart_printf("CH%u [UNIPOLAR] Raw: 0x%03X | mV: %ld\r\n",
                    channel, adc_raw, mv_at_adc_pin);
    }
}
RX = 0x3000
CH3 [BIPOLAR] Raw: 0x000 | SIGN: POS | Pin_mV: 0 | HW_Voltage: 0 mV
RX = 0x4000
CH4 [UNIPOLAR] Raw: 0x000 | mV: 0
RX = 0x5000
CH5 [UNIPOLAR] Raw: 0x000 | mV: 0
RX = 0x6CC7
CH6 [UNIPOLAR] Raw: 0xCC7 | mV: 7987
RX = 0x7089
CH7 [UNIPOLAR] Raw: 0x089 | mV: 334
RX = 0x0C0B
CH0 [UNIPOLAR] Raw: 0xC0B | mV: 7528
RX = 0x1BCC
CH1 [UNIPOLAR] Raw: 0xBCC | mV: 7374
RX = 0x2000
CH2 [BIPOLAR] Raw: 0x000 | SIGN: POS | Pin_mV: 0 | HW_Voltage: 0 mV

Problematic Code (Floating-Point – Program Gets Stuck

void ads8638_raw_to_voltage(uint16_t raw)
{
    uint8_t channel = (raw >> 12) & 0x07;
    uint16_t adc_raw = raw & 0x0FFF;

    float float_mv_pin = 0.0f;
    float float_hw_volts = 0.0f;

    const float HW_GAIN_FACTOR = 10.0f;

    if (channel == 2 || channel == 3)
    {
        int16_t signed_val;

        if (adc_raw & 0x800)
            signed_val = (int16_t)(adc_raw | 0xF000);
        else
            signed_val = (int16_t)adc_raw;

        float_mv_pin = ((float)signed_val * 10000.0f) / 2048.0f;
        float_hw_volts = (float_mv_pin * HW_GAIN_FACTOR) / 1000.0f;

        uart_printf("CH%u [BIPOLAR] Raw:0x%03X | Pin: %.2f mV | HW: %.3f V\r\n",
                    channel, adc_raw, float_mv_pin, float_hw_volts);
    }
    else
    {
        float_hw_volts = ((float)adc_raw * 10.0f) / 4095.0f;
        uart_printf("CH%u [UNIPOLAR] Raw:0x%03X | HW: %.3f V\r\n",
                    channel, adc_raw, float_hw_volts);
    }
}

Please guide me to resolve the issue