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.

TMS320F280038C-Q1: CLK2 - Clock integrity check using CPU TIMER2

Part Number: TMS320F280038C-Q1
Other Parts Discussed in Thread: C2000WARE

Tool/software:

Hello TI Team.

I have some questions about clcok integrity check using CPU TImer2 (CLK2 of FSM).

First, I have impemented logic as below usind SDL of C2000 5.0.0 version.

However, the result of oscillator test using CPUTimer2 is always FAIL.
I want to know the reason of this result and get the solution for this problem.
I'd appreciate it if you guys gave some guide or solution about this problem.

GLOBAL uint16_t HAL_MCUDiag_CLK2_ClockIntegrityCheck(void)
{
uint16_t u16returnVal = CTL_U_CLR;
STA_User_initOSCTimer2Test();

STL_OSC_CT_startTest(STA_User_oscTimer2Handle);

u16returnVal = STL_OSC_CT_stopTest(STA_User_oscTimer2Handle);

return u16returnVal;
}
void STA_User_initOSCTimer2Test(void)
{
STA_User_oscTimer2Obj.minCount = STA_USER_OSC_MIN_COUNT;
STA_User_oscTimer2Obj.maxCount = STA_USER_OSC_MAX_COUNT;
STA_User_oscTimer2Obj.clockSource = CPUTIMER_CLOCK_SOURCE_INTOSC1;
STA_User_oscTimer2Obj.prescaler = CPUTIMER_CLOCK_PRESCALER_1;

STA_User_oscTimer2Handle = &STA_User_oscTimer2Obj;
}


void STL_OSC_CT_startTest(const STL_OSC_CT_Handle oscTimer2Handle)
{
//
// Stop Timer2.
//
CPUTimer_stopTimer(CPUTIMER2_BASE);

//
// Clear overflow flag.
//
CPUTimer_clearOverflowFlag(CPUTIMER2_BASE);

//
// Disable interrupt.
//
CPUTimer_disableInterrupt(CPUTIMER2_BASE);

//
// Initialize Timer2 period to maximum.
//
CPUTimer_setPeriod(CPUTIMER2_BASE, STL_OSC_CT_PERIOD);

//
// Initialize pre-scaler counter to divide by 1 (SYSCLKOUT).
//
CPUTimer_setPreScaler(CPUTIMER2_BASE, 0U);

//
// Reload Timer2 counter.
//
CPUTimer_reloadTimerCounter(CPUTIMER2_BASE);

//
// Set prescaler to the input prescaler value.
// Select Timer2 clock source.
//
CPUTimer_selectClockSource(CPUTIMER2_BASE, oscTimer2Handle->clockSource,
oscTimer2Handle->prescaler);

//
// Start CPU Timer2.
//
CPUTimer_startTimer(CPUTIMER2_BASE);
}

//*****************************************************************************
//
// STL_OSC_CT_stopTest(const STL_OSC_CT_Handle oscTimer2Handle)
//
//*****************************************************************************
uint16_t STL_OSC_CT_stopTest(const STL_OSC_CT_Handle oscTimer2Handle)
{
uint32_t counterDelta;
uint16_t testStatus;

//
// Stop CPU Timer 2.
//
CPUTimer_stopTimer(CPUTIMER2_BASE);

//
// Get the Timer2 counter delta.
//
counterDelta = (uint32_t)STL_OSC_CT_PERIOD - CPUTimer_getTimerCount(CPUTIMER2_BASE);
//
// Check if Timer2 has overflowed or if Timer2 counter
// is outside of the bounds.
//
if((counterDelta <= oscTimer2Handle->minCount) ||
(counterDelta >= oscTimer2Handle->maxCount) ||
(CPUTimer_getTimerOverflowStatus(CPUTIMER2_BASE) > STL_OSC_CT_PERIOD))
{
//
// Set the global error flag.
//

STL_Util_setErrorFlag(STL_UTIL_OSC_TIMER2);

testStatus = STL_OSC_CT_FAIL;
}
else
{
testStatus = STL_OSC_CT_PASS;
}

return(testStatus);
}

Please let me know when you need more information about my logic.
Thank you in advance.
Best Regards,
Seungeun Lee.