#define LCD #include "freedom.h" #include void High_Int_Event(void); #pragma code high_vector = 0x08 void high_interrupt(void) { _asm GOTO High_Int_Event _endasm } #pragma code #pragma interrupt High_Int_Event void High_Int_Event(void) { BUZZER = 1; delay_ms(20); BUZZER = 0; INTCON3bits.INT2IF = 0; } void main() { unsigned char esito = 0; InitFreedom(); TRISBbits.TRISB2 = 1; //RB2/INT2 RCONbits.IPEN = 1; //architettura PIC18 INTCONbits.GIEH = 1; INTCONbits.GIEL = 1; //abilita interrupt su INT2 (JP9 in posizione 1-2) INTCON3bits.INT2IE = 1; INTCON2bits.INTEDG2 = 0; //fronte di discesa INTCON3bits.INT2IP = 1; // inizializzo il modulo I2C (400KHz @ 20 MHz) OpenI2C(MASTER, SLEW_ON); SSPADD = 12; // inizializzo la data set_days_RTCC(0x30); set_months_RTCC(0x12); set_years_RTCC(0x08); // inizializzo l'ora set_hours_RTCC(0x02); set_minutes_RTCC(0x57); set_seconds_RTCC(0x48); // imposto l'allarme enable_alarm_interrupt_RTCC(); set_minutes_alarm_RTCC(0x58, Enable_ON); WriteStringLCD("sleeping ..."); delay_ms(1000); BacklightLCD(TURN_OFF); Sleep(); //NOW DREAMING ... BacklightLCD(TURN_ON); Line2LCD(); WriteStringLCD("wake up"); while (1); }