Hello,
Reference is made to the “MCX N Reference Manual” Rev. 7.
The FRDM-MCX947 board with the NXP SDK v25.06.00 is used here.
The configuration for PTP looks like this:
#ifdef ENET_PTP1588FEATURE_REQUIRED
enet_ptp_config_t ptpConfig;
memset(&ptpConfig, 0x00, sizeof(ptpConfig));
config.specialControl = kENET_MulticastAllEnable | kENET_StoreAndForward;
ptpConfig.fineUpdateEnable = true;
ptpConfig.ptp1588V2Enable = true;
ptpConfig.tsRollover = kENET_DigitalRollover;
config.ptpConfig = &ptpConfig;
config.ptpClkHz = 50000000U;
#endif
The digital rollover mode is used here. For the GPIO, PORT 3 pin 20 is used:
CLOCK_EnableClock(kCLOCK_Port3);
const port_pin_config_t pin_config = {
kPORT_PullDisable,
kPORT_LowPullResistor,
kPORT_FastSlewRate,
kPORT_PassiveFilterDisable,
kPORT_OpenDrainDisable,
kPORT_LowDriveStrength,
kPORT_MuxAlt1,
kPORT_InputBufferEnable,
kPORT_InputNormal,
kPORT_UnlockRegister};
/* PORT3_20 is configured as TRIG_OUT0 */
PORT_SetPinConfig(PORT3, 20U, &pin_config);
CLOCK_EnableClock(kCLOCK_InputMux);
INPUTMUX->EXT_TRIG[0] = INPUTMUX_EXT_TRIGN_EXT_TRIG_INP(0x2F);
In order to output a PPS signal at all, the TSCFUPDT bit and the ADDEND register must be set:
ENET0->MAC_TIMESTAMP_CONTROL |= ENET_MAC_TIMESTAMP_CONTROL_TSCFUPDT_MASK;
ENET_Ptp1588CorrectTimerInFine(ENET0, 0xFFFFFFFF);
This now creates a PPS period of 1000 005 596ns. The clock runs too fast here. As PTP clock 50MHz is specified here, which leads to a MAC_SUB_SECOND_INCREMENT of 20.
If I have understood correctly, then the fine correction can be done via the ADDEND register. The new ADDEND (Anew) is calculated as follows:
Anew = Aold * (Time wrong / 1e9)
In my case, this gives the following value:
Anew = 0xFFFFFFFF * (1000005596 / 1e9) = 0x100005DE2
The new value cannot be used here because it is too large for the register.
How can the clock be slowed down in such a case?
I have now made the following change and set the MAC_SUB_SECOND_INCREMENT to 21.
This produces a period of 952 384 638ns with an ADDEND of 0xFFFFFFFF. The formula now results in the following new ADDEND:
Anew = 0xFFFFFFFF * (952384638 / 1e9) = 0xF3CF7AC8
With this new value, I now get a period of 999 999 675ns, which is almost ideal.
Is this the right way or am I missing something here?
From the description on page 3058, "70.3.8.9 System timeregister module" I don't really get the hang of how else to set it.
I have running an RT1170 board with the ENET-IP. INC, INC_CORR and ATCOR are used there. But here on the N947 with the ENET_QoS I have the problems.
Best regards,
Michael