Hello,
I am using the AM335x ICE with the Industrial SDK 1.0.0.2, with SYS/BIOS 6.33.00.19, on CCS 5.1.0.09000. I am using the example EtherCAT project (ecat_appl). Right now, I am trying to implement a timer that triggers every 250 microseconds. Therefore, I am planning on using DMTimer3 for this purpose. I noticed that the ecat_appl example project is already using DMTimer2 for the system timer for SYS/BIOS.
I am trying to initialize DMTimer3 in main() in tiescappl.c, but I am having some difficulties with it. I am trying to implement the dmtimer by using the following StartweWare example applications for evmAM335x: dmtimerCounter.c, demoTimer.c, and demoMain.c.
In the StarterWare examples for the DMTimer, the ARM Interrupt Controller is always initialized by calling IntAINTCInit(). However, if I call this in main() in my application, it causes the interrupts for the DMTimer2 (SYS/BIOS system timer) to not be serviced. The program hangs, even though interrupts are enabled for DMTimer2 (it is configured by SYS/BIOS). I have verified this by seeing that the INTC_PENDING_IRQ2 register (0x482000D8) has a value of 0x00000010, and the DMTimer2 IRQSTATUS register (0x48040028) has a value of 0x00000002, indicating that the IRQ is pending. It seems that IntAINTCInit() is preventing the DMTimer2 ISQ from being serviced, even though IntAINTCInit() is called before any interrupt configuration or peripheral configuration for DMTimer2.
I have tried working around this issue by simply not calling IntAINTCInit(). This makes me nervous because IntAINTCInit() is always called in the dmtimer examples. The issue I am experiencing now is that the HWI for DMTimer3 is not being being called, even though the interrupt IRQ for DMTimer3 is pending. I have enabled the interrupt at the system level and the peripheral level, and have registered the ISR for DMTimer3, so I am not sure what is wrong. Here is the code I have for main() in tiescappl.c:
Void main()
{
DISABLE_ESC_INT()
// just to make sure we can't get early Ecat IRQs...
Task_Params taskParams;
Task_Params_init(&taskParams);
taskParams.
priority = 4;
tsk1 = Task_create (task1, &taskParams, NULL);
mmuInit();
// needed first
SetBoardType(AM335X_BOARD_TYPE_ICE );
//AM335X_BOARD_TYPE_ICE : AM335X_BOARD_TYPE_IDK
led_init();
PINMUX_Config();
timer2Init();
boardType = GetBoardType();
if(AM335X_BOARD_TYPE_IDK == boardType)
PowerPWM();
ICSS_Init();
PRUSSPinMux_Config(0x01);
// PRUSS pinmuxing
spiInit();
// C2000 communication for motor current reads
//---------------------!!! my code begins here !!!-----------------------------
/* This function will enable clocks for the DMTimer3 instance */
DMTimer3ModuleClkConfig();
/* Initialize the ARM Interrupt Controller */
// TODO: Note: Initializing the ARM Interrupt Controller should be done, according to examples, but for some reason it is causing issues with DMTimer2 for the SYS/BIOS system timer
//IntAINTCInit();
/* Registering ADC_Timer_ISR */
IntRegister(SYS_INT_TINT3, ADC_Timer_ISR);
/* Set the priority */
IntPrioritySet(SYS_INT_TINT3, 0, AINTC_HOSTINT_ROUTE_IRQ);
/* Enable the system interrupt */
IntSystemEnable(SYS_INT_TINT3);
/* Enable IRQ in CPSR */
IntMasterIRQEnable();
/* Configure the DMTimer for Auto-reload and no-compare mode */
DMTimerModeConfigure(SOC_DMTIMER_3_REGS, DMTIMER_AUTORLD_NOCMP_ENABLE);
/* Load the counter with the initial count value */
DMTimerCounterSet(SOC_DMTIMER_3_REGS, ADC_TIMER_INITIAL_COUNT);
/* Load the load register with the reload count value */
DMTimerReloadSet(SOC_DMTIMER_3_REGS, ADC_TIMER_RLD_COUNT);
/* Stop/Reset the DMTimer */
Stop_ADC_Timer();
/* This function will enable the interrupt for the DMTimer3 instance */
DMTimerIntEnable(SOC_DMTIMER_3_REGS, DMTIMER_INT_OVF_EN_FLAG);
//----------------------------------------!!! my code ends here !!!-------------------------------------------------------
if( AM335X_BOARD_TYPE_ICE == boardType )
{
uartInstance = 5;
}
else if(AM335X_BOARD_TYPE_IDK == boardType)
{
uartInstance = 3;
}
UartOpen(uartInstance,NULL);
UARTPutString(uartInstance,"TI EtherCAT Demo Application Build - ");
UARTPutString(uartInstance,APPL_BUILD_VER);
//Disable PRUs - This is to ensure PRUs are not running when application is not initialized
PRUSSDRVPruDisable(0);
PRUSSDRVPruDisable(1);
BIOS_start();
}
I would like some help setting up DMTimer3 properly.
Thanks.