楼主多看一下寄存器的说明及BSP的范例。
#define SYS_GET_BOD_INT_FLAG() (SYS->BODCR & SYS_BODCR_BOD_INTF_Msk)
BOD范例包在SYS范例中。
\M051SeriesBSP_CMSIS_Rev3.00.002\SampleCode\StdDriver\SYS\KEIL
/* Unlock protected registers for Brown-Out Detector settings */
SYS_UnlockReg();
/* Check if the write-protected registers are unlocked before BOD setting and CPU Reset */
if(SYS_IsRegLocked() == 0)
{
printf("Protected Address is Unlocked\n");
}
/* Enable Brown-Out Detector, and set Brown-Out Detector voltage 2.7V */
SYS_EnableBOD(SYS_BODCR_BOD_INTERRUPT_EN, SYS_BODCR_BOD_VL_2_7V);
/* Enable BOD IRQ */
NVIC_EnableIRQ(BOD_IRQn);
/*---------------------------------------------------------------------------------------------------------*/
/* Brown Out Detector IRQ Handler */
/*---------------------------------------------------------------------------------------------------------*/
void BOD_IRQHandler(void)
{
/* Clear BOD Interrupt Flag */
SYS_CLEAR_BOD_INT_FLAG();
printf("Brown Out is Detected\n");
} |