Hi Bill,
I just did exactly what you are looking for with a MOD5282 board. I used the Pulse Accmulator, that way there is no CPU overhead, but it looks like the 5272 doesn't have that feature. My design also has an anenometer and a geiger counter that send pulses. Since the 5285 only has two pulse accumulators, I implemented the third one with an IRQ.
IRQ method was fairly simple:
Basically, the ISR just adds one to a global long variable and clears the interrupt. That way it has low overhead and the global variable just accumulates the pulses.
ISR looks like this:
unsigned long int Pulse;
Code: Select all
INTERRUPT( IRQ1_ISR, 0x2100 )
{
Pulse++;
sim.eport.epfr = IRQ1_ON;
}
Initializer looks like this:
Code: Select all
#define INTC0 0 /*Interrupt Controller 0 is the one that has the IRQ pins*/
#define IRQ_1 1
#define IRQ_LEVEL 1 /*Levels are 1 (lowest) to 7 (highest)*/
#define IRQ_PRIORITY 8 /*IRQ's are fixed mid level priority */
#define IRQ1_ON 0x02
#include <..\mod5282\system\sim5282.h>
#include <cfinter.h> /*this has to come afer include <ucos.h> I think.*/
#include <pins.h>
void InitializeIRQS(void) {
sim.eport.epddr = 0x00; /*Set Edge Port ddr to input */
J2[43].function(PINJ2_43_IRQ1_FET); /*FET = Falling Edge Trigger */
sim.eport.epier |= IRQ1_ON;
SetIntc(INTC0, (long) IRQ1_ISR, IRQ_1, IRQ_LEVEL, IRQ_PRIORITY);
}
Then all you should have to do is read "Pulse" and divide by the "tips per inch" of the tipping bucket.
That's the easy part. Next you have to figure out how to show a rolling 10 minute, hourly and daily reading.
Hope you can port it to the 5272.
I isolated with a schmidt trigger, but I think the IRQ's are schmidt inputs. I don't think that lightening cares how you isolate, I put a lightening rod (14 guage copper wire pointing up above the unit and grounded) with a view to bleeding off the static.
Good luck with this. Let me know if I can help further.
Ed