Index: /webserver/example/EnergyMeters/Source/EnergyMeters/Meters.c =================================================================== --- /webserver/example/EnergyMeters/Source/EnergyMeters/Meters.c (revision 59) +++ /webserver/example/EnergyMeters/Source/EnergyMeters/Meters.c (revision 60) @@ -30,4 +30,8 @@ + +portLONG meterIntStatus = 0; /* which meter interrupts were triggered? (bitwise 0 to 7) */ + + int rtcHOURS; int rtcMINUTES; @@ -48,5 +52,5 @@ { - /* this runs every 1000 ms */ + /* this runs every METERS_INT_CHECK_INTERVAL_MS ms */ basementGasCalculation(); @@ -71,5 +75,5 @@ rtcSECONDS = RTC_CTIME0 & MASKSEC; // Read Second - xSemaphoreTake( xMetersSemaphore, 1000 ); /* timeout 1 sec */ + xSemaphoreTake( xMetersSemaphore, METERS_INT_CHECK_INTERVAL_MS ); /* timeout METERS_INT_CHECK_INTERVAL_MS ms */ @@ -145,4 +149,35 @@ { + if ( (meterIntStatus & (1<<10)) != 0) + { + handleMeterTick(METER_INDEX_TST); + meterIntStatus &= (~(1<<10)); + } + + if ( (meterIntStatus & (1<<0)) != 0) + { + handleMeterTick(METER_INDEX_GAS); + meterIntStatus &= (~(1<<0)); + } + + if ( (meterIntStatus & (1<<1)) != 0) + { + handleMeterTick(METER_INDEX_EL1); + meterIntStatus &= (~(1<<1)); + } + + if ( (meterIntStatus & (1<<2)) != 0) + { + handleMeterTick(METER_INDEX_EL2); + meterIntStatus &= (~(1<<2)); + } + + if ( (meterIntStatus & (1<<3)) != 0) + { + handleMeterTick(METER_INDEX_AU1); + meterIntStatus &= (~(1<<3)); + } + + } Index: /webserver/example/EnergyMeters/Source/EnergyMeters/Meters_ISRs.c =================================================================== --- /webserver/example/EnergyMeters/Source/EnergyMeters/Meters_ISRs.c (revision 59) +++ /webserver/example/EnergyMeters/Source/EnergyMeters/Meters_ISRs.c (revision 60) @@ -13,4 +13,5 @@ extern xTickCount; /* millisecond tick counter */ +extern meterIntStatus; int globalValue = 0; @@ -33,25 +34,30 @@ if ((IO2_INT_STAT_R & (1 << 10)) != 0) /* P2.10 interrupt triggered - SPI Load Switch */ { - handleMeterTick(METER_INDEX_TST); + meterIntStatus |= (1<<10); + //handleMeterTick(METER_INDEX_TST); IO2_INT_CLR |= (1<<10); } if ((IO2_INT_STAT_R & (1 << 0)) != 0) /* P0.0 interrupt triggered - connector J4, Pin 0*/ { - handleMeterTick(METER_INDEX_GAS); + meterIntStatus |= (1<<0); + //handleMeterTick(METER_INDEX_GAS); IO2_INT_CLR |= (1<<0); } if ((IO2_INT_STAT_R & (1 << 1)) != 0) /* P0.1 interrupt triggered - connector J4, Pin 1*/ { - handleMeterTick(METER_INDEX_EL1); + meterIntStatus |= (1<<1); + //handleMeterTick(METER_INDEX_EL1); IO2_INT_CLR |= (1<<1); } if ((IO2_INT_STAT_R & (1 << 2)) != 0) /* P0.3 interrupt triggered - connector J4, Pin 3*/ { - handleMeterTick(METER_INDEX_EL2); + meterIntStatus |= (1<<2); + //handleMeterTick(METER_INDEX_EL2); IO2_INT_CLR |= (1<<2); } if ((IO2_INT_STAT_R & (1 << 3)) != 0) /* P0.4 interrupt triggered - connector J4, Pin 4*/ { - handleMeterTick(METER_INDEX_AU1); + meterIntStatus |= (1<<3); + //handleMeterTick(METER_INDEX_AU1); IO2_INT_CLR |= (1<<3); } @@ -59,4 +65,5 @@ //if ((IO2_INT_STAT_R & (1 << 4)) != 0) /* P0.2 interrupt triggered - connector J4, Pin 2*/ //{ + // meterIntStatus |= (1<<4); // handleMeterTick(METER_INDEX_AU2); // IO2_INT_CLR |= (1<<4); Index: /webserver/example/EnergyMeters/Source/EnergyMeters/MetersIncludes.h =================================================================== --- /webserver/example/EnergyMeters/Source/EnergyMeters/MetersIncludes.h (revision 56) +++ /webserver/example/EnergyMeters/Source/EnergyMeters/MetersIncludes.h (revision 60) @@ -11,4 +11,7 @@ #define METER_INDEX_AU1 4 /* index of Auxiliary input 1 */ #define METER_INDEX_AU2 5 /* index of Auxiliary input 1 */ + + +#define METERS_INT_CHECK_INTERVAL_MS 100 /* how often (in ms) do we check if one of the I/O lines has triggered */