各位:
我现在要每1ms处理一个事件。我不知道如何获取1ms时间。
请问:如果我使用void buzzerInit(void) timer3设置1ms中断一次的话。中断函数在哪里?
在从机代码中,频繁键入hal_sleep 的PM2模式,这时候timer3 的时钟源会被停止。这样会导致timer3不准确,而如果不频繁进入PM2 功耗又比较大?
请问还有其他方式能准确的获取到1ms么?
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.
各位:
我现在要每1ms处理一个事件。我不知道如何获取1ms时间。
请问:如果我使用void buzzerInit(void) timer3设置1ms中断一次的话。中断函数在哪里?
在从机代码中,频繁键入hal_sleep 的PM2模式,这时候timer3 的时钟源会被停止。这样会导致timer3不准确,而如果不频繁进入PM2 功耗又比较大?
请问还有其他方式能准确的获取到1ms么?
hi :
1、你必须确保能在osal_run_system函数中调用如下红色代码。
#if defined( POWER_SAVING )
else // Complete pass through all task events with no activity?
{
osal_pwrmgr_powerconserve(); // Put the processor/system into sleep
}
#endif
2、在osal_pwrmgr_powerconserve中确保能执行到如下红色代码
{
uint32 next;
halIntState_t intState;
// Should we even look into power conservation
if ( pwrmgr_attribute.pwrmgr_device != PWRMGR_ALWAYS_ON )
{
// Are all tasks in agreement to conserve
if ( pwrmgr_attribute.pwrmgr_task_state == 0 )
{
// Hold off interrupts.
HAL_ENTER_CRITICAL_SECTION( intState );
// Get next time-out
next = osal_next_timeout();
// Re-enable interrupts.
HAL_EXIT_CRITICAL_SECTION( intState );
// Put the processor into sleep mode
OSAL_SET_CPU_INTO_SLEEP( next );
}
}
}
#endif /* POWER_SAVING */
3、如果能进入OSAL_SET_CPU_INTO_SLEEP( next );后,里面变量halPwrMgtMode 可设置进入PM2或Pm3.
hi T_MAC:
我调了一下我自己的代码,发现你所说的两个地方都是调到了的,#define OSAL_SET_CPU_INTO_SLEEP(m) halSleep(m) /* interface to HAL sleep */
我不是很清楚为什么在halSleep(m)里它问什么会调用LL_PowerOnReq( wakeForRF )这个函数?这个函数调用之后,定时器2就被打开了,程序也就不能进入
PM2或者PM3,请问你的代码里是不是也调用了这个函数?假如调用了,你测试出来的电流是0.04毫安吗?
希望你能回复,谢谢