|
![]() Oscillators/PCA/Timers/SMBus/UART/SPI
![]() PCA capture event while CCFn is pendig - what will happen to already captured value?
|
| next newest topic | next oldest topic |
| Author | Topic: PCA capture event while CCFn is pendig - what will happen to already captured value? |
|
jacobk New Member |
Hallo everyone, I am using the C0851F500 and want to measure time with the PCA. Does any of you know what will happen to a already captured PCA value if all of the following conditions are true: Will the value in PCA0CPn be preserved or overwritten with the new value? Thanks in advance, IP: Logged |
|
Scotty Member |
Hi jacobk, excerpt from datasheet: But, from your question I assume that you're experiencing some data loss with your current software. Or is there another reason for your question? If so, post your code and describe the hardware circuit and the input signals. Generally, a ISR should be kept as short as possible. In best cases a ISR saves the data to a buffer and informs the main application about the new data. This ensures that each interrupt can be serviced. Regards, Scotty IP: Logged |
|
jacobk New Member |
Thanks for your reply Scotty. The reason for my question is that i DON'T wont each of the PCA CCFn interrupts to be serviced. I try to explain why. The timestamps i want to measure are used by a subroutine to control a dc motor speed. This subroutine is called from within Timer2_ISR which is serviced all 10ms. I don't need the timestamps to be measured all the time but rather two times between each Timer2_ISR. Now we assume that a capture event occurs at the execution time of Timer2_ISR. Even though the CCFn interrupt is masked a value will be captured in PCA0CPn. I solved the problem by clearing the CCFn flag at the end of Timer2_ISR. No more distortions so far. Nevertheless, i'm not sure a about this. I hoped that someone would know a document which is clear about that point. Regards, [This message has been edited by jacobk (edited August 05, 2010).] [This message has been edited by jacobk (edited August 05, 2010).] IP: Logged |
|
erikm Member |
within Timer2_ISR which is serviced all 10ms. I don't need the timestamps to be measured all the time but rather two times between each Timer2_ISR. there may be something in your post I do not get, but the above seems to have an obvious answer: why not a counter in the Timer2_ISR. Erik IP: Logged |
|
jacobk New Member |
Hi Erik, i don't see your point. Why should i use a counter in the Timer2_ISR? What should i count there except how often this ISR has been serviced? Besides, my code is working now as i expect it to work. So the answer to my original question is no longer essential to complete my task. But i don't like it not to be really sure about such fundamental questions. Just in case, in my timezone we have 8:50pm right now. So don't wonder about my delays of posting. Regards, [This message has been edited by jacobk (edited August 05, 2010).] IP: Logged |
|
erikm Member |
Jacob, I don't see your point. Why should i use a counter in the Timer2_ISR? What should i count there except how often this ISR has been serviced? if (count) Erik IP: Logged |
|
jacobk New Member |
Hi Erik, from your code snippet i would say that in this way a "timestamp" would be captured every third Timer2 interrupt. But with the term "timestamp" i was referring to a PCA counter value captured at a time when a positive edge is sensed on a CEXn pin. This signal comes from the dc-motor quadrature encoder and is asynchronous to the Timer2_ISR intervals. I already solved that problem like i have described in my second post: Here some pseudo code: main { Timer2_ISR{ PCA0_ISR{ Timer2_ISR|.|-----|...............|-----| [This message has been edited by jacobk (edited August 06, 2010).] [This message has been edited by jacobk (edited August 06, 2010).] [This message has been edited by jacobk (edited August 06, 2010).] IP: Logged |
|
erikm Member |
in a previous post: "there may be something in your post I do not get" evidently so Erik "if I heard what you thought you said we would understand each other" IP: Logged |
All times are CT (US) | next newest topic | next oldest topic |
![]() |
|
Have you seen our MCU Knowledge Base?