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:
- The
tsvo_setpoint
is always 4095, which seems incorrect. This value is derived from thecalculate_DAC_value(target_temperature)
function. - The
read_current_temperature()
function appears to work fine and returns a reasonable temperature value. However, the logic inspi_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