BF606 core1中修改定时器由timer0 改为timer2,中断服务程序在core0启动后不执行
您好,
近期我在对timer0的中断服务程序进行修改时,发现两个问题:
1是 在已有的timer0中断服务程序中再增加一个1us的定时器中断,服务程序只对一个数进行自增计时,程序在core0 启动后不执行中断服务程序
2是 将定时器由timer0 改为timer2,中断服务程序在core0启动后不执行,而改为timer1或者timer0则可以。
附上 time 的初始化好服务程序代码
#define SEL_TIMER2_NUM 0 //使用timer0
//#define SEL_TIMER2_NUM 2 //使用timer2
#if TIMER2_USED
//----------------------------------------------------------------------------------------------------------------------------------------------
//2022.05.13 add timer2
/*****************************************************************************************
* 函数名称 : Timer2Init ()
* 作 者 : Joytan
* 输 入 : period - 定时器的周期值 ,不能大于65535
* 输 出 : -
* 返 回 : -
* 日 期 : 2022.05.13
* 注 释 : 定时器timer2初始化, 用于1us 计时用
*****************************************************************************************/
void Timer2Init (uint32_t period)
{
ADI_TMR_RESULT eTmrResult = ADI_TMR_SUCCESS;
adi_sec_SetCoreID(INTR_TIMER0_TMR2, ADI_SEC_CORE_1);
// adi_sec_SetCoreID(sid, (ADI_SEC_CORE_ID) LOCAL_CORE)) ;
adi_int_InstallHandler(INTR_TIMER0_TMR2, /* IID for supplemental interrupt 0 */
&Timer2_ISR, /* our interrupt handler */
NULL, /* pass the connection as its argument */
true); /* enable the interrupt immediately */
/* Open the timer */
if( (eTmrResult = adi_tmr_Open (SEL_TIMER2_NUM, Timer2Memory, ADI_TMR_MEMORY, Timer2_ISR, NULL, &pTimer2)) != ADI_TMR_SUCCESS)
{
//DEBUG_PRINT("Timer open failed 0x%08X \n", eTmrResult);
}
/* Set the mode to PWM OUT */
if((eTmrResult = adi_tmr_SetMode(
pTimer2,
ADI_TMR_MODE_CONTINUOUS_PWMOUT)) != ADI_TMR_SUCCESS)
{
//DEBUG_PRINT("Failed to open timer in PWM out mode 0x%08X \n", eTmrResult);
}
/* Set the IRQ mode to get interrupt after timer counts till TMR_PERIOD register value */
if((eTmrResult = adi_tmr_SetIRQMode(
pTimer2,ADI_TMR_IRQMODE_WIDTH_DELAY // ADI_TMR_IRQMODE_WIDTH_DELAY
)) != ADI_TMR_SUCCESS)
{
//DEBUG_PRINT("Failed to set the timer IRQ mode 0x%08X \n", eTmrResult);
}
/* Set the Period */
if((eTmrResult = adi_tmr_SetPeriod(
pTimer2,
period)) != ADI_TMR_SUCCESS)//TIMER_PERIOD
{
// DEBUG_PRINT("Failed to set the timer Period 0x%08X \n", eTmrResult);
}
/* Set the timer width */
if((eTmrResult = adi_tmr_SetWidth(
pTimer2,
TIMER2_WIDTH)) != ADI_TMR_SUCCESS)
{
// DEBUG_PRINT("Failed to set the timer Width 0x%08X \n", eTmrResult);
}
/* Set the timer Delay */
if((eTmrResult = adi_tmr_SetDelay(
pTimer2,
TIMER2_DELAY)) != ADI_TMR_SUCCESS)
{
// DEBUG_PRINT("Failed to set the timer Delay 0x%08X \n", eTmrResult);
}
/* Enable the timer to stop gracefully */
if((eTmrResult = adi_tmr_EnableGracefulStop(
pTimer2,
true)) != ADI_TMR_SUCCESS)
{
// DEBUG_PRINT("Failed to enable the timer to stop gracefully 0x%08X \n", eTmrResult);
}
eTmrResult = adi_tmr_SetClkInSource(pTimer2, ADI_TMR_CLKIN_SYSCLK);
eTmrResult = adi_tmr_SetPulsePolarity(pTimer2,true);
eTmrResult = adi_tmr_DisableOutput(pTimer2, false);
eTmrResult = adi_tmr_SetEmuRun(pTimer2, true);
/* Enable the timer*/
if((eTmrResult = adi_tmr_Enable(
pTimer2,
true)) != ADI_TMR_SUCCESS)
{
// DEBUG_PRINT("Failed to enable the timer 0x%08X \n", eTmrResult);
}
}
//TIMER0 Timer 1
//#pragma section( "data1")
void Timer2_ISR(void *pCBParam, uint32_t Event, void *pArg)
{
static OS_CPU_SR cpu_sr;
unsigned int uiTIMASK;
// OS_ENTER_CRITICAL();
/* Anomaly 16000030 workaround */
// uiTIMASK = cli();
switch((ADI_TMR_EVENT)Event)
{
case ADI_TMR_EVENT_DATA_INT :
#if 1
// 添加自己的代码
{
#if test_clock
//for test consuming time
START_CYCLE_COUNT(start_count);
#endif
//系统1us软时钟 计时
TMD_System_Clocktestcnt++;
//微秒计数, joytan 2022.05.13
if(++TMD_System_ClockuSec>= 10)//1us 计时,计时1000us =1ms 清零
{
SoftCounter++;
TMD_System_ClockuSec=0;
// TMD_System_ClockMSec++;//used for protect 1ms timer counter
}
#if test_clock
STOP_CYCLE_COUNT(end_count,start_count);
//DEBUG_PRINT("Task_Gather end_count= %d ",(long)end_count);
#endif
}
#endif
break;
default:
// asm("emuexcpt;");
break;
}
// OS_EXIT_CRITICAL();
// sti(uiTIMASK);
return;
}
#endif
software
ADSP-BF607
bf606
CCES V2.10.0
blackfin
Please log in to reply.