cc3200 RTC timer打断 sl_sendto
各位大神好,
我最近在用LDPS模式,所以在iddleprofile里修改了一下,用rtc 定时器来做UDP发送的定时器(开始把cc_idle_task_pm()函数屏蔽掉了,其实进不进LDPS都会出现这个问题)
我把发送任务放到大循环里,利用标志位每50ms发送一次,一开始发送任务可以进行,但是当发送了几百几千次(有时候是几十次,随机性很强)之后,sl_sendto停止发送,又经过几个循环之后,sl_sendto返回SL_EAGAIN(-11 手册上标注的try again),之后就一直返回-11.
如果换一个timer,比如timer0,timer1都没用这个问题。
SetTimerAsWkUp()是iddleprofile里原来就有的,创建唤醒定时器,SetTimerAsWkUp2()是我用论坛行看见的,把中间四句删掉(在timercallback里只是重设timer而不是重新创建)。这个RTC 的timer运行一直没问题,就是发送函数有问题。
void TimerCallback(void *vParam)
{
LPDS_Flag2=1;
SetTimerAsWkUp2();
}
cc_hndl SetTimerAsWkUp()
{
cc_hndl tTimerHndl;
struct cc_timer_cfg sRealTimeTimer;
struct u64_time sInitTime, sIntervalTimer;
//
// setting up Timer as a wk up source and other timer configurations
//
sInitTime.secs = 0;
sInitTime.nsec = 0;
cc_rtc_set(&sInitTime);
sRealTimeTimer.source = HW_REALTIME_CLK;
sRealTimeTimer.timeout_cb = TimerCallback;
sRealTimeTimer.cb_param = NULL;
tTimerHndl = cc_timer_create(&sRealTimeTimer);
sIntervalTimer.secs = LPDS_DUR_SEC;
sIntervalTimer.nsec = LPDS_DUR_NSEC;
cc_timer_start(tTimerHndl, &sIntervalTimer,OPT_TIME_ABS_VALUE);
return(tTimerHndl);
}
cc_hndl SetTimerAsWkUp2()
{
cc_hndl tTimerHndl;
struct cc_timer_cfg sRealTimeTimer;
struct u64_time sInitTime, sIntervalTimer;
//
// setting up Timer as a wk up source and other timer configurations
//
sInitTime.secs = 0;
sInitTime.nsec = 0;
cc_rtc_set(&sInitTime);
/*
sRealTimeTimer.source = HW_REALTIME_CLK;
sRealTimeTimer.timeout_cb = TimerCallback;
sRealTimeTimer.cb_param = NULL;
tTimerHndl = cc_timer_create(&sRealTimeTimer); */
timer_created++;
sIntervalTimer.secs = LPDS_DUR_SEC;
sIntervalTimer.nsec = LPDS_DUR_NSEC;
cc_timer_start(tTimerHndl, &sIntervalTimer,OPT_TIME_ABS_VALUE);
return(tTimerHndl);
}
//udpclient main loop
while(1)
{
if(LPDS_Flag2==1)
{
GPIO_IF_LedToggle(MCU_RED_LED_GPIO);
iStatus= sl_SendTo( 0, &wifi_send_buf, 1, 0,( SlSockAddr_t *)&sAddr_Flag, iAddrSize_Flag);
GPIO_IF_LedToggle(MCU_RED_LED_GPIO);
LPDS_Flag2=0;
UART_PRINT("istatus is %d",iStatus);
}
}
socket我设置成了nonblock模式
sl_SetSockOpt(iSockID,SOL_SOCKET,SL_SO_NONBLOCKING, &enableOption,sizeof(enableOption));
如果不这样设置的话,从sl_sendto这里就直接阻塞了,调到idle task里面回不来了了