In order to synchronize with a PPS signal from a GPS to generate 10000 equal time slice, we need to adjust the MOD of a flex timer at regular intervals. During debugging on our ls1020, we notices that a free running timer and a timer which continually adjusted the MOD register (10000 times per second) would drift by 5us in a second, which in our case would be 5% drift after 1 second. Is there an explanation for this? Can it be confirmed the following process is correct to change the MOD register on the fly?
1- Verify the FTMEN bit is set.
2- Write the MOD register with the desired value.
3- Set the SYNCONF register with SYNCMODE = 1, SWWRBUF = 1
4- Set the SYNC register with CNTMIN = 1
5- Set the SYNC register with SWSYNC = 1
Thank you in advance for your response.
Here are the value of the test registers:
FTM TEST1:3, ptimer:0x2005061c, ptimer:0x220ee000
0 Status And Control (FTM_SC ), Ptr:0x220ee000, Value:0x48000000
4 Counter (FTM_CNT ), Ptr:0x220ee004, Value:0x8b1c0000
8 Modulo (FTM_MOD ), Ptr:0x220ee008, Value:0x983a0000
12 Channel (n) Status And Control (FTM_C0SC ), Ptr:0x220ee00c, Value:0x00000000
16 Channel (n) Value (FTM_C0V ), Ptr:0x220ee010, Value:0x00000000
20 Channel (n) Status And Control (FTM_C1SC ), Ptr:0x220ee014, Value:0x00000000
24 Channel (n) Value (FTM_C1V ), Ptr:0x220ee018, Value:0x00000000
28 Channel (n) Status And Control (FTM_C2SC ), Ptr:0x220ee01c, Value:0x00000000
32 Channel (n) Value (FTM_C2V ), Ptr:0x220ee020, Value:0x00000000
36 Channel (n) Status And Control (FTM_C3SC ), Ptr:0x220ee024, Value:0x00000000
40 Channel (n) Value (FTM_C3V ), Ptr:0x220ee028, Value:0x00000000
44 Channel (n) Status And Control (FTM_C4SC ), Ptr:0x220ee02c, Value:0x00000000
48 Channel (n) Value (FTM_C4V ), Ptr:0x220ee030, Value:0x00000000
52 Channel (n) Status And Control (FTM_C5SC ), Ptr:0x220ee034, Value:0x00000000
56 Channel (n) Value (FTM_C5V ), Ptr:0x220ee038, Value:0x00000000
60 Channel (n) Status And Control (FTM_C6SC ), Ptr:0x220ee03c, Value:0x00000000
64 Channel (n) Value (FTM_C6V ), Ptr:0x220ee040, Value:0x00000000
68 Channel (n) Status And Control (FTM_C7SC ), Ptr:0x220ee044, Value:0x00000000
72 Channel (n) Value (FTM_C7V ), Ptr:0x220ee048, Value:0x00000000
76 Counter Initial Value (FTM_CNTIN ), Ptr:0x220ee04c, Value:0x00000000
80 Capture And Compare Status (FTM_STATUS ), Ptr:0x220ee050, Value:0x00000000
84 Features Mode Selection (FTM_MODE ), Ptr:0x220ee054, Value:0x05000000
88 Synchronization (FTM_SYNC ), Ptr:0x220ee058, Value:0x01000000
92 Initial State Channels Output (FTM_OUTINIT ), Ptr:0x220ee05c, Value:0x00000000
96 Output Mask (FTM_OUTMASK ), Ptr:0x220ee060, Value:0x00000000
100 Function For Linked Channels (FTM_COMBINE ), Ptr:0x220ee064, Value:0x00000000
104 Deadtime Insertion Control (FTM_DEADTIME ), Ptr:0x220ee068, Value:0x00000000
108 FTM External Trigger (FTM_EXTTRIG ), Ptr:0x220ee06c, Value:0x00000000
112 Channels Polarity (FTM_POL ), Ptr:0x220ee070, Value:0x00000000
116 Fault Mode Status (FTM_FMS ), Ptr:0x220ee074, Value:0x00000000
120 Input Capture Filter Control (FTM_FILTER ), Ptr:0x220ee078, Value:0x00000000
124 Fault Control (FTM_FLTCTRL ), Ptr:0x220ee07c, Value:0x00000000
128 Quadrature Decoder Ctrl&Status (FTM_QDCTRL ), Ptr:0x220ee080, Value:0x00000000
132 Configuration (FTM_CONF ), Ptr:0x220ee084, Value:0x00000000
136 FTM Fault Input Polarity (FTM_FLTPOL ), Ptr:0x220ee088, Value:0x00000000
140 Synchronization Configuration (FTM_SYNCONF ), Ptr:0x220ee08c, Value:0x80020000
144 FTM Inverting Control (FTM_INVCTRL ), Ptr:0x220ee090, Value:0x00000000
148 FTM Software Output Control (FTM_SWOCTRL ), Ptr:0x220ee094, Value:0x00000000
152 FTM PWM Load (FTM_PWMLOAD ), Ptr:0x220ee098, Value:0x00000000
FTM TEST2:6, ptimer:0x20050ff0, ptimer:0x22100000
0 Status And Control (FTM_SC ), Ptr:0x22100000, Value:0x48000000
4 Counter (FTM_CNT ), Ptr:0x22100004, Value:0x032f0000
8 Modulo (FTM_MOD ), Ptr:0x22100008, Value:0x983a0000
12 Channel (n) Status And Control (FTM_C0SC ), Ptr:0x2210000c, Value:0x00000000
16 Channel (n) Value (FTM_C0V ), Ptr:0x22100010, Value:0x00000000
20 Channel (n) Status And Control (FTM_C1SC ), Ptr:0x22100014, Value:0x00000000
24 Channel (n) Value (FTM_C1V ), Ptr:0x22100018, Value:0x00000000
28 Channel (n) Status And Control (FTM_C2SC ), Ptr:0x2210001c, Value:0x00000000
32 Channel (n) Value (FTM_C2V ), Ptr:0x22100020, Value:0x00000000
36 Channel (n) Status And Control (FTM_C3SC ), Ptr:0x22100024, Value:0x00000000
40 Channel (n) Value (FTM_C3V ), Ptr:0x22100028, Value:0x00000000
44 Channel (n) Status And Control (FTM_C4SC ), Ptr:0x2210002c, Value:0x00000000
48 Channel (n) Value (FTM_C4V ), Ptr:0x22100030, Value:0x00000000
52 Channel (n) Status And Control (FTM_C5SC ), Ptr:0x22100034, Value:0x00000000
56 Channel (n) Value (FTM_C5V ), Ptr:0x22100038, Value:0x00000000
60 Channel (n) Status And Control (FTM_C6SC ), Ptr:0x2210003c, Value:0x00000000
64 Channel (n) Value (FTM_C6V ), Ptr:0x22100040, Value:0x00000000
68 Channel (n) Status And Control (FTM_C7SC ), Ptr:0x22100044, Value:0x00000000
72 Channel (n) Value (FTM_C7V ), Ptr:0x22100048, Value:0x00000000
76 Counter Initial Value (FTM_CNTIN ), Ptr:0x2210004c, Value:0x00000000
80 Capture And Compare Status (FTM_STATUS ), Ptr:0x22100050, Value:0x00000000
84 Features Mode Selection (FTM_MODE ), Ptr:0x22100054, Value:0x05000000
88 Synchronization (FTM_SYNC ), Ptr:0x22100058, Value:0x00000000
92 Initial State Channels Output (FTM_OUTINIT ), Ptr:0x2210005c, Value:0x00000000
96 Output Mask (FTM_OUTMASK ), Ptr:0x22100060, Value:0x00000000
100 Function For Linked Channels (FTM_COMBINE ), Ptr:0x22100064, Value:0x00000000
104 Deadtime Insertion Control (FTM_DEADTIME ), Ptr:0x22100068, Value:0x00000000
108 FTM External Trigger (FTM_EXTTRIG ), Ptr:0x2210006c, Value:0x00000000
112 Channels Polarity (FTM_POL ), Ptr:0x22100070, Value:0x00000000
116 Fault Mode Status (FTM_FMS ), Ptr:0x22100074, Value:0x00000000
120 Input Capture Filter Control (FTM_FILTER ), Ptr:0x22100078, Value:0x00000000
124 Fault Control (FTM_FLTCTRL ), Ptr:0x2210007c, Value:0x00000000
128 Quadrature Decoder Ctrl&Status (FTM_QDCTRL ), Ptr:0x22100080, Value:0x00000000
132 Configuration (FTM_CONF ), Ptr:0x22100084, Value:0x00000000
136 FTM Fault Input Polarity (FTM_FLTPOL ), Ptr:0x22100088, Value:0x00000000
140 Synchronization Configuration (FTM_SYNCONF ), Ptr:0x2210008c, Value:0x00000000
144 FTM Inverting Control (FTM_INVCTRL ), Ptr:0x22100090, Value:0x00000000
148 FTM Software Output Control (FTM_SWOCTRL ), Ptr:0x22100094, Value:0x00000000
152 FTM PWM Load (FTM_PWMLOAD ), Ptr:0x22100098, Value:0x00000000
Look at NXP Application Notes about synchronization using FTM:
https://www.nxp.com/docs/en/application-note/AN4410.pdf
and
https://www.nxp.com/docs/en/application-note/AN4560.pdf
The LS1021a Flextimer is the same as Kinetis Flextimer.
Have a great day,
Pavel Chubakov
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------