PDA

View Full Version : Cicles count



MegaADY
- 23rd October 2006, 19:03
Hello all,
Maybe this is a stupid question, but .. I would really like to know the answer... I can not answer myself, reading the datasheets...
So , basically I have a 16f628@20MHz and I want to input a 3.5MHz signal and to count from there 380 pulses. And during this count, to read serially a bit. after 380 is reached, read the next bit serially, and so on.
Any help would be greatly appreciated.
thanks a lot.

Zenon
- 23rd October 2006, 22:16
First, to measure 380 cycles of a 3.5MHz signal (at TTL level) use Timer1 as a counter. You can preload Timer1 registers with 65157 and when an overflow is reached, either use polling or interrupts to proceed with the next step. Timer1 can read much higher frequencies than 3.5MHz.
Then, use the Hardware Uart during the counting for serial comms, just make sure you check to see if the counter overflow flag is set or an interrupt was issued.

Hope this gives you a start.

Zenon

MegaADY
- 23rd October 2006, 22:34
Thanks for your advice. I theory I know how to make it work.
Thae problem is that after reading a lot of threads related to this topic, It's a big messup in my head related to TMR0.
I know that this kind of question are not agreed around here, but... I would really need a working program which can count a few hundred cycles. I am testing it with 16f628a@20MHz
Thanks in advance.

Acetronics2
- 24th October 2006, 13:01
Hi, Mega

TMR1 of the 16F628 has a feature called "CAPTURE" ... have a look to Microchip DATAs, and you'll see how it flags an interrupt for as much as you want counts ...

Darrel's instant interrupts also look great here ...

As a joke ... if ONLY 3.5 Mhz input must be counted ( hé, hé ... ) a NE567 PLL could make a good enabling gate command.

Alain