我是在定时器中断里通过串口发送数据,PVD中断设置的2.9V,掉电时在PVD中断里保存数据,然后上电时读取,可是偶尔会出现上电读取的数据是前一次保存的(也就是上一次的数据没有保存上),如果把定时器中断关了,串口发送在while里进行,保存读取都没有问题,请问这是怎么回事啊?定时器中断与PVD中断的优先级如下:
if(TIM == TIM1)
NVIC_InitStructure.NVIC_IRQChannel = TIM1_UP_IRQn;
else if(TIM == TIM2)
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = PVD_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
PVD中断如下:
void PVD_IRQHandler(void)
{
EXTI_ClearITPendingBit(EXTI_Line16);
if(PWR_GetFlagStatus(PWR_FLAG_PVDO))
{
EE_WriteVariable(0x5555, r);
EE_WriteVariable(0x6666, zero);
PWR_ClearFlag(PWR_FLAG_PVDO);
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
---------------------------------
这不清楚了.
一周热门 更多>