while((* (reg8 *) CYREG_RESET_SR0) != 0); 
// 6.) set the voltage monitor trip thresholds 
// under "voltage monitors". 0x66 is 3.2 v, 0x55 is 2.95v 
// RESET_CR0 (high nibble is LVI-A threshold, low nibble is LVI-D threshold) 
(* (reg8 *) CYREG_RESET_CR0) = 0x55; 
// 7.) select the Fixed Function Path for interrupt vector 0 (LVD-A/D interrupt) 
(* (reg8 *) CYREG_IDMUX_IRQ_CTL0) &= ~0x03; 
// 8.) register the previously defined ISR address in the interrupt vector table for vector 0 
// blarf is a made up name to show how the process works 
CY_SET_REG16(CYDEV_INTC_VECT_MBASE + 2*0, blarf); 
// 9.) we can change the default priority setting if we desire. 
(* (reg8 *) CYREG_INTC_PRIOR0) = 0x07 << 5; 
// 10.) enable the interrupt (vector 0) 
(* (reg8 *) CYREG_INTC_SET_EN0) |= 0x01; 
// 11.) enable global interrupts 
CYGlobalIntEnable; 
while(1) 
{ 
// Test is a pin connected to an LED 
Test_Write(0); 
} 
} 
经测试,该程序工作正常,当电源电压下降到指定阀值后将产生中断并运行中断服务子程序,即LED灯点亮。 
作者: 田江学 主任应用工程师 赛普锐思半导体(上海)有限公司