[TMS320C6720 EVM] RTI Timer 테스트 - 1초 만들기
TMS320C67xx RTI Timer 관련 자료
TMS320C672x는 C671x에 있는 일반적인 타이머 모듈이 없고 The Real-Time Interrupt Module (RTI) 라고 하는 타이머 모듈이 2채널 존재 한다.
TMS320C6720 RTI Timer 인터럽트 핸들러
TMS320C6720 RTI Timer 초기화 함수
TMS320C6720 RTI Timer 테스트 예제 소스코드
TMS320C6720의 RTI0를 이용하여 1ms 인터럽트로 구동하고 메인함수에서 1초마다 한번씩 LED를 점등하는 예제이다.
TMS320C67xx RTI Timer 관련 자료
TMS320C672x는 C671x에 있는 일반적인 타이머 모듈이 없고 The Real-Time Interrupt Module (RTI) 라고 하는 타이머 모듈이 2채널 존재 한다.
TMS320C6720 RTI Timer 인터럽트 핸들러
//time interval = 1ms
void RTI_TimerHandler(void)
{
Bool intEvent;
CSL_Status status;
/* Read the interrupt flag register */
status = CSL_rtiGetHwStatus (hRti, CSL_RTI_QUERY_INT0_STATUS, &intEvent);
//----------------------------------------
Led1Toggle();
gTimeTick1++;
//----------------------------------------
/* Clear the interrupt */
status = CSL_rtiHwControl (hRti, CSL_RTI_CMD_CLEAR_INT0, &intEvent);
}
void RTI_TimerHandler(void)
{
Bool intEvent;
CSL_Status status;
/* Read the interrupt flag register */
status = CSL_rtiGetHwStatus (hRti, CSL_RTI_QUERY_INT0_STATUS, &intEvent);
//----------------------------------------
Led1Toggle();
gTimeTick1++;
//----------------------------------------
/* Clear the interrupt */
status = CSL_rtiHwControl (hRti, CSL_RTI_CMD_CLEAR_INT0, &intEvent);
}
TMS320C6720 RTI Timer 초기화 함수
void RTI_Setup(void)
{
CSL_RtiObj rtiObj;
CSL_Status status = CSL_SOK;
CSL_RtiHwSetup hwSetup = CSL_RTI_HWSETUP_DEFAULTS;
CSL_RtiHwSetup hwSetupRead;
Uint16 count = 0;
/* clear local data structures */
memset (&rtiObj, 0, sizeof (CSL_RtiObj));
memset (&hwSetup, 0, sizeof (CSL_RtiHwSetup));
memset (&hwSetupRead, 0, sizeof (CSL_RtiHwSetup));
/* Initalize the RTI csl module */
status = CSL_rtiInit (NULL);
/* Open csl module */
hRti = CSL_rtiOpen (&rtiObj, CSL_RTI, NULL, &status);
if ((status != CSL_SOK) || (hRti == NULL)) return;
/* Setup hardware parameters */
hwSetup.blk0ExtnCntl = CSL_RTI_CAPTURE_EVENT_SOURCE1;
hwSetup.blk1ExtnCntl = CSL_RTI_CAPTURE_EVENT_SOURCE1;
hwSetup.compareUpCntrs.compareUpCntr0 = UC_COMP_VALUE;
hwSetup.compVal.comp0Val = COMPARE0_VALUE;
hwSetup.compVal.comp1Val = COMPARE1_VALUE;
hwSetup.compVal.comp2Val = COMPARE2_VALUE;
hwSetup.compVal.comp3Val = COMPARE3_VALUE;
hwSetup.updateCompVal.updateComp0Val = UPDATECOMPARE_VALUE;
hwSetup.updateCompVal.updateComp1Val = UPDATECOMPARE_VALUE;
hwSetup.updateCompVal.updateComp2Val = UPDATECOMPARE_VALUE;
hwSetup.updateCompVal.updateComp3Val = UPDATECOMPARE_VALUE;
hwSetup.preLoadWatchdog = PRELOAD_VALUE;
/* Enable compIntr0 alone */
hwSetup.intConfig.compIntr0En = TRUE;
hwSetup.intConfig.compIntr1En = FALSE;
hwSetup.intConfig.compIntr2En = FALSE;
hwSetup.intConfig.compIntr3En = FALSE;
/* Stop Rti Block0 counters */
status = CSL_rtiHwControl (hRti, CSL_RTI_CMD_STOP_BLOCK0, NULL);
/* Setup rti module */
status = CSL_rtiHwSetup (hRti, &hwSetup);
/* verify the hwsetup configuration */
status = CSL_rtiGetHwSetup (hRti, &hwSetupRead);
/* Start Rti Block0 counters */
status = CSL_rtiHwControl (hRti, CSL_RTI_CMD_START_BLOCK0, NULL);
}
{
CSL_RtiObj rtiObj;
CSL_Status status = CSL_SOK;
CSL_RtiHwSetup hwSetup = CSL_RTI_HWSETUP_DEFAULTS;
CSL_RtiHwSetup hwSetupRead;
Uint16 count = 0;
/* clear local data structures */
memset (&rtiObj, 0, sizeof (CSL_RtiObj));
memset (&hwSetup, 0, sizeof (CSL_RtiHwSetup));
memset (&hwSetupRead, 0, sizeof (CSL_RtiHwSetup));
/* Initalize the RTI csl module */
status = CSL_rtiInit (NULL);
/* Open csl module */
hRti = CSL_rtiOpen (&rtiObj, CSL_RTI, NULL, &status);
if ((status != CSL_SOK) || (hRti == NULL)) return;
/* Setup hardware parameters */
hwSetup.blk0ExtnCntl = CSL_RTI_CAPTURE_EVENT_SOURCE1;
hwSetup.blk1ExtnCntl = CSL_RTI_CAPTURE_EVENT_SOURCE1;
hwSetup.compareUpCntrs.compareUpCntr0 = UC_COMP_VALUE;
hwSetup.compVal.comp0Val = COMPARE0_VALUE;
hwSetup.compVal.comp1Val = COMPARE1_VALUE;
hwSetup.compVal.comp2Val = COMPARE2_VALUE;
hwSetup.compVal.comp3Val = COMPARE3_VALUE;
hwSetup.updateCompVal.updateComp0Val = UPDATECOMPARE_VALUE;
hwSetup.updateCompVal.updateComp1Val = UPDATECOMPARE_VALUE;
hwSetup.updateCompVal.updateComp2Val = UPDATECOMPARE_VALUE;
hwSetup.updateCompVal.updateComp3Val = UPDATECOMPARE_VALUE;
hwSetup.preLoadWatchdog = PRELOAD_VALUE;
/* Enable compIntr0 alone */
hwSetup.intConfig.compIntr0En = TRUE;
hwSetup.intConfig.compIntr1En = FALSE;
hwSetup.intConfig.compIntr2En = FALSE;
hwSetup.intConfig.compIntr3En = FALSE;
/* Stop Rti Block0 counters */
status = CSL_rtiHwControl (hRti, CSL_RTI_CMD_STOP_BLOCK0, NULL);
/* Setup rti module */
status = CSL_rtiHwSetup (hRti, &hwSetup);
/* verify the hwsetup configuration */
status = CSL_rtiGetHwSetup (hRti, &hwSetupRead);
/* Start Rti Block0 counters */
status = CSL_rtiHwControl (hRti, CSL_RTI_CMD_START_BLOCK0, NULL);
}
TMS320C6720 RTI Timer 테스트 예제 소스코드
TMS320C6720의 RTI0를 이용하여 1ms 인터럽트로 구동하고 메인함수에서 1초마다 한번씩 LED를 점등하는 예제이다.
void main()
{
SystemInit();
//Led Init..
Led1Init();
Led2Init();
Led1Off();
Led2Off();
DebugPrint("[TMS320C6720 EVM] Test Program - RTI Timer.\n");
//RTI Timer 초기
RTI_Init();
while(1)
{
//1000ms/1ms = 1000 => 1초
if(gTimeTick1>1000)화
{
gTimeTick1 = 0;
Led2Toggle();
}
}
}
{
SystemInit();
//Led Init..
Led1Init();
Led2Init();
Led1Off();
Led2Off();
DebugPrint("[TMS320C6720 EVM] Test Program - RTI Timer.\n");
//RTI Timer 초기
RTI_Init();
while(1)
{
//1000ms/1ms = 1000 => 1초
if(gTimeTick1>1000)화
{
gTimeTick1 = 0;
Led2Toggle();
}
}
}
반응형