闲话不说。 直接上程序,主要是加了WWDG看门狗并且使用它的中断。主程序里放了看门狗的初始化,中断里面放了看门狗喂狗。其它都按照你2楼的程序没改动。单独使用你的程序没问题,systick中断对它也没影响。但是WWDG通不过,因为WWDG提到它的中断只有复位才能关闭,难道是这个原因,导致你的关中断对它无效?
//【主程序部分】
int main(void) { #ifdef DEBUG debug(); #endif
RCC_Configuration();
NVIC_Configuration();
//---------------????????????????-------------------------------- RCC_APB1PeriphClockCmd(RCC_APB1Periph_WWDG, ENABLE); WWDG_SetPrescaler(WWDG_Prescaler_8); WWDG_SetWindowValue(65); WWDG_Enable(127); WWDG_ClearFlag(); WWDG_EnableIT(); //-----------------?????????????------------------------------
I2C_Comm_Init(I2C1, 100000, 0xA0);
re1=I2C_Comm_MasterWrite(I2C1, 0xa0, 0, Tx1_Buffer, 2); re2=I2C_Comm_MasterRead(I2C1, 0xa0, 0, Rx1_Buffer, 5); re2=I2C_Comm_MasterRead(I2C1, 0xa0, 0, Rx1_Buffer, 3); re2=I2C_Comm_MasterRead(I2C1, 0xa0, 0, Rx1_Buffer, 2); re2=I2C_Comm_MasterRead(I2C1, 0xa0, 0, Rx1_Buffer, 1); while(1) { re3 = I2C_Comm_MasterWrite(I2C1, 0xa0, 0, Tx1_Buffer, 8); if (re3!=NO_ERR) GPIO_SetBits(GPIOA, GPIO_Pin_0); re4 = I2C_Comm_MasterRead(I2C1, 0xa0, 0, Rx1_Buffer, 8); if (re4!=NO_ERR) GPIO_SetBits(GPIOA, GPIO_Pin_1); }
}
void NVIC_Configuration(void) { NVIC_InitTypeDef NVIC_InitStructure; #ifdef VECT_TAB_RAM /* Set the Vector Table base location at 0x20000000 */ NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0); #else /* VECT_TAB_FLASH */ /* Set the Vector Table base location at 0x08000000 */ NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0); #endif
//------------------??????????????------------------------------- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); NVIC_InitStructure.NVIC_IRQChannel = WWDG_IRQChannel; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_Init(&NVIC_InitStructure); //-----------------??????????????--------------------------------- }
//【中断WWDG部分】 void WWDG_IRQHandler(void) { //----------------?????????????????---------------------- WWDG_SetCounter(0x7F);
WWDG_ClearFlag(); //NOP(); //----------------????????????????------------------------ }
|