Hi, this set of questions is a result of going through the functional safety documentation for the TMS320F280049C uC. One of the many options is to validate the functionality of peripherals through some sort of loop back. In particular, for the purposes of this post I have a few lines of enquiry as to whether it is possible to perform loopback tests without the need for external hardware connections.
GPIO Loopback
Initially, I thought that it may be possible to have internal loop backs to test the operation of the GPIO input and outputs. Taking at the TMS320F28004x Technical Reference Manual (September 2020), it would look as though the GPIO can ONLY operate in either the input or output mode (image clip from TRF below)
However, I had a play at trying to see if it was possible to simultaneously read/write of the GPIO by using the XBAR. My question is whether this is an acceptable method performing GPIO loopback testing, in the view of functional safety? I tested this with the code snippet below on device, and it appears to work successfully. The flags to indicate whether the set/clear tests succeeded are all set at the end of the program when running under debug. It appears that it can read the XBAR output using input GPIOs, and can read the output GPIOs using the XBAR input. Note that I was using C2000 v3.04.00, CCS 10.3, and CGT 22.6.0.
Furthermore, given that not all GPIOs can be muxed to the XBAR, would it be valid to only test application critical GPIOs using this method from the perspective of functional safety? I.e. if there is a heart-beat LED blinky, that can be ignored as it does not affect functionality in any way.
#include <gpio.h>
#include <xbar.h>
#include <pin_map.h>
/**
* main.c
*/
int main(void)
{
// TEST GPIO INPUT: OUTPUTXBAR1 -> GPIO2 (via INPUTXBAR1)
GPIO_setMasterCore(2, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_2_OUTPUTXBAR1);
GPIO_setDirectionMode(2, GPIO_DIR_MODE_IN);
GPIO_setPadConfig(2, GPIO_PIN_TYPE_STD);
XBAR_setOutputMuxConfig(XBAR_OUTPUT1, XBAR_OUT_MUX01_INPUTXBAR1);
XBAR_enableOutputMux(XBAR_OUTPUT1, XBAR_MUX01);
XBAR_setInputPin(XBAR_INPUT1, 0xFFFE);
bool inputIsSetTest = false;
if (GPIO_readPin(2) != 0U) {
inputIsSetTest = true;
}
XBAR_setInputPin(XBAR_INPUT1, 0xFFFF);
bool inputIsClearTest = false;
if (GPIO_readPin(2) == 0U) {
inputIsClearTest = true;
}
// TEST GPIO OUTPUT: GPIO -> INPUTXBAR1
GPIO_setMasterCore(2, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_2_GPIO2);
GPIO_setDirectionMode(2, GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(2, GPIO_PIN_TYPE_STD);
GPIO_writePin(2, 0);
XBAR_setInputPin(XBAR_INPUT1, 2);
GPIO_writePin(2, 1);
XBAR_clearInputFlag(XBAR_INPUT_FLG_INPUT1);
// NO XBAR FILTERING, to allow the XBAR flag to get set in the few clock cycles
// between the flag clear and get
bool outputIsSetTest = false;
if (XBAR_getInputFlagStatus(XBAR_INPUT_FLG_INPUT1) != 0U) {
outputIsSetTest = true;
}
GPIO_writePin(2, 0);
XBAR_clearInputFlag(XBAR_INPUT_FLG_INPUT1);
// NO XBAR FILTERING, to allow the XBAR flag to get set in the few clock cycles
// between the flag clear and get (in this case, we expect it not to get set)
bool outputIsClearTest = false;
if (XBAR_getInputFlagStatus(XBAR_INPUT_FLG_INPUT1) == 0U) {
outputIsClearTest = true;
}
return 0;
}
Analog Loopback
My next questions are on analog loopbacks. I see that there is a previous post about DAC-ADC loopbacks here:
https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1065020/tms320f280049-dac-to-adc-loopback-check-xbar-loopback/3941144?tisearch=e2e-sitesearch&keymatch=GPIO%252520loopback#3941144
It appears that the only way to do internal ADC loopback tests is if the DAC pins also happen to be muxed on the same pin. Unfortunately for the TMS320F280049C in our application, this appears not to be useful. Again from the technical reference manual, it appears that only the ADC pins A0 and A1 (shown below) can mux to the DAC out. Is this a correct interpretation?
Given this, I also want to clarify whether this is true of performing loop back tests of the PGA peripherals. From the reference manual, it does not appear to be possible to loop back a DAC output into a PGA input pin internally. Can I also confirm whether this interpretation is correct?
Thanks!
Emily