/*---------------------------------------------------------------------------------------------------------*/
/* */
/* Copyright(c) 2015 Nuvoton Technology Corp. All rights reserved. */
/* */
/*---------------------------------------------------------------------------------------------------------*/
//***********************************************************************************************************
// Nuvoton Technology Corp.
// E-mail: MicroC-8bit@nuvoton.com
//***********************************************************************************************************
bit EA_Save_bit;
#include <stdio.h>
#include "N79E715.h"
#include "Typedef.h"
#include "Define.h"
#include "Common.h"
#include "Delay.h"
#include "ISR.h"
#include "wdt.h"
#include "Version.h"
#define set_BODEN\
EA_Save_bit=EA;\
EA=0;\
TA=0xAA;\
TA=0x55;\
PMCR |= SET_BIT7;\
EA=EA_Save_bit;
#define clr_BODEN\
EA_Save_bit=EA;\
EA=0;\
TA=0xAA;\
TA=0x55;\
PMCR &= CLR_BIT7;\
EA=EA_Save_bit;
#define set_BOV\
EA_Save_bit=EA;\
EA=0;\
TA=0xAA;\
TA=0x55;\
PMCR |= SET_BIT6;\
EA=EA_Save_bit;
#define clr_BOV\
EA_Save_bit=EA;\
EA=0;\
TA=0xAA;\
TA=0x55;\
PMCR &= CLR_BIT6;\
EA=EA_Save_bit;
#define set_BORST\
EA_Save_bit=EA;\
EA=0;\
TA=0xAA;\
TA=0x55;\
PMCR |= SET_BIT4;\
EA=EA_Save_bit;
#define clr_BORST\
EA_Save_bit=EA;\
EA=0;\
TA=0xAA;\
TA=0x55;\
PMCR &= CLR_BIT4;\
EA=EA_Save_bit;
//-----------------------------------------------------------------------------------------------------------
UINT8 CounterBOF = 0;
void main()
{
InitialUART0_Timer1(9600); // 9600 Baud Rate [url=home.php?mod=space&uid=72445]@[/url] 11.0592MHz
printf ("\n*===================================================================");
printf ("\n* Name: N79E715 BOD Sample Code.");
printf ("\n*===================================================================");
set_BODEN //Enable BOD
set_BOV //Select BOD38
clr_BORST //Disable BOD reset when VDD drops below VBOD
EBO = 1; //Enable BOD Interrupt
EA = 1;
while(1)
{
if(PMCR & 0x01) //BOS = 1: VDD is higher than VBOD
{
P0 = PMCR;
printf ("\nVDD is higher than VBOD");
}
else //BOS = 0: VDD is lower than VBOD
{
P0 = PMCR;
printf ("\nVDD is lower than VBOD");
}
Delay1ms(2000);
}
}
//-----------------------------------------------------------------------------------------------------------
void BOD_ISR(void) interrupt 8 // Vector @ 0x43
{
clr_BOF;//Two conditions will assert BOF,
//One is "VDD rise above VBOD";
//Another is "VDD fall below VBOD"
CounterBOF++;
P2 = CounterBOF;
}
//-----------------------------------------------------------------------------------------------------------
|