PDA

View Full Version : CCp module question.



robert0
- 2nd January 2007, 10:09
I'm learning CCp module.

There is something I don't understand yet.
I want to know the length of the first 16 rising edges of an incoming stream to decide whether it's the right stream or noise..

I have to check when a single rising edge has come (CCP1CON % 00000101), then switch to CCP1CON %00000111( 16th edge capture), Timer1 starts, then finally when another event occured read the CCPR1 bytes and decide if this is the correct timing.

Is this the correct procedure?

It seems to me that this way i need 17 rising edges (the first for let Timer1 start and the other 16 for having the correct event on CCP module).Where i'm wrong....


Thanks .
Roberto

Darrel Taylor
- 2nd January 2007, 11:14
I think it would be better to leave it on "Every Rising Edge". Start the timer on the first edge, count 15 more interrupts, then stop the timer.

Of course, for that you can use an external interrupt (without the CCP) to do the same thing.
<br>

robert0
- 2nd January 2007, 13:09
Thanks for your prompt reply.

I read somewhere that CCP module is less intrusive than "normal "interrupt loops.
If i could read 16 high edges i'll get just one interrupt and my job would be done. I'm already using Usart,I2c,PORTB, PORTB0,tmro, tmr2 interrupts and when polling for incoming data sometimes i'm loosing an interrupt.

Roberto

Darrel Taylor
- 3rd January 2007, 00:28
That's true, it can be "Less Intrusive", under certain conditions.

But like you said, you would need 17 low-high transitions to get the reading you're looking for. If that works for you then CCP is a good way to go. But if it has to be 16, then there's no way to start the timer at the right time.

I hope you're using ASM interrupts, cause all that stuff will never work with ON INTERRUPT.
<br>