Zur Übersicht - INFO - Neueste 50 Beiträge - Neuer Beitrag - Suchen - Zum C-Control-I-Forum - Zum C-Control-II-Forum

Re: Synchronisationsproblem mit Input-Capture und Timer-Overflow Interrupt Kategorie: Programmierung C (von PepeV - 5.05.2012 14:45)
Als Antwort auf Re: Synchronisationsproblem mit Input-Capture und Timer-Overflow Interrupt von Torsten - 5.05.2012 6:26
Ich nutze:
C-Control Pro Mega128
Hi Torsten,

So you want to quit the game? That's a pity.
Still I have two remarks.

1. It seems that the problem with the dwords only arises with constants. So it might be
circumvented by replacing constants with dword variables.

2. I suspected that you did not believe in my solution. Let me therefore prove that it should
work, at least theoretically.

Suppose the signal period is 131071 (2^16 + 2^16-1) cpu ticks.
Then the capture would read 65535 (2^16-1) cpu ticks.
The slow timer ticks at a rate that is 2^12 times slower than the cpu (and the capture timer).
Then, ideally spoken, the slow timer should indicate 131071/2^12 = 31 slow ticks
(of 0,278 ms each).
In practice, all sort of events block the in time handling of both IRQ functions. Say this causes
an error in the counter of the the slow timer of + or - 1.5 ms, that is about + or - 6 slow ticks.
So in practice, the slow timer will indicate anything between 25 and 37 ticks.
Now perform my calculation with the two extremes:
Overflows = ((25+8)*4096 - 65535) / 65536 = 1 (which is correct)
Overflows = ((37+8)*4096 - 65535) / 65536 = 1 (which is also correct)

Now suppose the signal period is 131072 (2^16 + 2^16) cpu ticks.
Then the capture would read 0 cpu ticks.
Ideally spoken, the slow timer should indicate 131072/2^12 = 32 slow ticks.
In practice, the slow timer will indicate anything between 26 and 38 ticks.
Perform the calculations with the two extremes:
Overflows = ((26+8)*4096 - 0) / 65536 = 2 (which is correct)
Overflows = ((38+8)*4096 - 0) / 65536 = 2 (which is also correct)

If you want, try other signal periods. My calculation will always show to be correct. I think it is
only a matter of programming to make it work in practice. Pity we didn't succeed.

Regards,
Pepe


    Antwort schreiben


Antworten:

Re: Synchronisationsproblem mit Input-Capture und Timer-Overflow Interrupt (von Torsten - 6.05.2012 8:34)
    Re: Synchronisationsproblem mit Input-Capture und Timer-Overflow Interrupt (von PepeV - 7.05.2012 20:33)