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.

LAUNCHXL-F28379D: Issue with SPI Controller Function in TMS320F28379D Code

Part Number: LAUNCHXL-F28379D
Other Parts Discussed in Thread: TMS320F28379D

Hello TI Community,

I am working on a project using the TMS320F28379D MCU where I need to implement SPI communication. I am facing an issue with a specific part of my code, particularly in the spi_updateController() function, which doesn't seem to be functioning correctly.

Here's the relevant code snippet:

void spi_updateController() {
short currentTemperature = read_current_temperature();

tsvo_err = tsvo_setpoint - read_current_temperature();
tsvo_acc = tsvo_err * tsvo_pg;
tsvo_acc += tsvo_mem;

tsvo_out = tsvo_acc >> 16;
if (tsvo_out > MAX_DAC_VALUE) tsvo_out = MAX_DAC_VALUE;
if (tsvo_out < MIN_DAC_VALUE) tsvo_out = MIN_DAC_VALUE;

spi_TX(tsvo_out);

tsvo_mem += tsvo_err * tsvo_ig;

// Other code for data handling and display
DEVICE_DELAY_US(40000);
}

The function is supposed to calculate a control output (tsvo_out) based on the current temperature, which is then transmitted via SPI. However, I am encountering an issue where the calculated error (tsvo_err) and consequently the control output (tsvo_out) are not as expected. The tsvo_err becomes zero, leading to tsvo_out also being zero, which is not correct for my application.

Here are some specific points where I need help:

  1. The tsvo_setpoint is always 4095, which seems incorrect. This value is derived from the calculate_DAC_value(target_temperature) function.
  2. The read_current_temperature() function appears to work fine and returns a reasonable temperature value. However, the logic in spi_updateController() does not process this value correctly.

I would greatly appreciate any insights or suggestions on how to resolve these issues or what might be causing the problem in the spi_updateController() function. Thank you in advance for your assistance.28379d_sci_11_29.zip

  • Hi Nero, 

    This doesn't seem to be a SPI communication issue, is that correct? It seems you are seeing an issue with the logic of the value (tsvo_out) that you calculate and then transmit via SPI at the end of the function? 

    The tsvo_setpoint will always be 4095 because it is calculated using hardcoded values. (This is because you have target_temperature = 60, so when this is passed into calculate_DAC_value(60), the voltage value 60 is greater than maxVoltage (3.7), and the function thus returns the value (3.7/3.7) *4095 = 4095. 

    How are you reading these values when debugging? Are you using the CCS register view with continuous refresh on? What are the typical values of read_current_temperature and what is the tsvo_out value when you stop the program at spi_TX(tsvo_out) and is the value being transmitted properly after that function? If you are getting 0, that could likely indicated that tsvo_out < MIN_DAC_VALUE and is capping at 0. 

    Best Regards,

    Allison