RCM5700 - counting pulses for a specified time

Is there a way to count pulses for a specific amount of time, say 100ms? I’ve looked through the documentation and browsed the site, but found nothing.

You could do something like (if I’m reading correctly that you want to monitor external pulses):

unsigned long ul0,msec;
long count;
ul0=MS_TIMER;
msec=100;
count=0;
while(MS_TIMER

thanks Alan , that works. As a novice to the rabbits,I’ve been interfacing various things to it. This is a TI TAOS TSL230R light to freq converter. I didn’t think it was so easy, just connecting to pin PC3. I thought I had to set the port for input first. I got counts, but they may be inaccurate. Could the code count a high multiple times, if proc speed is fast and pulses are slow?

Also, I noted “MS_TIMER”, looked all through the docs and I can’t find it.

Actually, good catch. I just threw together a reply earlier. I’d have to check, but PC3 might default to input by default. You’d want to set whatever pin you’re using to input to be safe, i.e. BitWrPortI(PCDDR,&PCDDRShadow,0,3);. Also, I’m sure you know, but I just arbitrarily picked Port C and pin 3. I’ll have to look up where MS_TIMER is for you later, but I believe it’s in the Dynamic C user manual. I’ve been in the office all day and am ready to go home. They turn off the AC in the building at 6, so it’s starting to get stuffy in here. Anyway, MS_TIMER is derived from the real time clock. As such, it shouldn’t matter what speed you run the board at. As a test, you could turn the clock doubler off and should get the same result. As far as your result, don’t forget to divide by whatever time interval you’re using (in this case, 100 ms) to get the frequency.

Alan
Found MS_TIMER under global_variables. My count was inaccurate, it was 3600 about 30 times what it should have been. ambient light in my room set the output to 120 Hz, so it was counting a single high multiple times. I changed the code to this

ul0=MS_TIMER;
msec=1000;
count=0;
while(MS_TIMER

Woops! Wow, I must be getting old. I forgot to tell you to add a delay to that, but you seemed to have fixed the problem another way. I guess I should double check things before hitting the reply button!

Thanks for your input Alan. It works well, and I learned to count pulses with the 5700. Time to try another IC interface.