ABCDEFGHIJKLMNOPQRSTU
1
Calculation of:=
2
#define CPU_LOAD_PERCENT 16*CLK_PHASES*((390625*4096)/FREQOSC)
3
4
UDB TYPECLOCK TYPEFREQOSCCLK_PHASESCALCULATED CPU_LOAD_PERCENTExisting HARD CODED VALUECalculation agrees with code
5
UDB3Chrystal16000000464006400Yes
6
FRC8X5898240041736.1111111744No, but close
7
UDB4Chrystal32000000216001600Yes
8
9
The above calculations are currently being questioned ....
10
11
12
Check calculations in light of Guilio's comments
13
dspic family reference manual makes clear that timer clock is using Fosc / 2 i.e. Fcy and not the Chrystal speed directly .... the following is for the UDB4 driven from the Chystal ...
14
Chrystal speedFcyTimer 5 set to interrupt at...._cpu_timer at full load (theoretical) per secondNew CPU LOAD PERCENT
15
320000001600000040963906.251677.7216
16
17
18
Note: I've used the word theoretical above as Timer 5 is priority 6, and the Servo Out PWM generator is at priority 7.
19
20
dspic 33F family reference manual, chapter on timers :-
21
http://ww1.microchip.com/downloads/en/DeviceDoc/70205D.pdf
22
23
Setting up of T5 timer:-
24
http://code.google.com/p/gentlenav/source/browse/trunk/libUDB/background.c#122
25
26
27
NEW NOTE:
28
PDH 2/7/2012I have measure the maximum CPU load emprically. With the standard code of MatrixPilot a maxed out CPU will show as 95% cpu load currently.
29
30
This is because on a UDB4, the CPU_LOAD_PERCENT should actually be 1677 and not 1600. This difference explains the 5% cpu load shortfall.
31
So the current CPU_LOAD_PERCENT of 1600, in matrixpilot is approximately correct.
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100