Skip to main content
Associate
February 13, 2026
Question

Cannot get PTP Timestamp working on STM32H563

Hi, I'm following the "Programming guidelines for IEEE 1588 timestamping" from page 2792 of the RM0481. I've been working on this specifically for quite a while and I cannot even get the timestamp nanosecond or second registers to move. It feels to me like a clock issue, but unless I'm mistaken, the PTP clock (clk_ptp_ref_i from the manual(p.456)) is the same as the ETH clock (PLL1Q), which I've verified is running because I'm successfully using NetXDuo to negotiate DHCP and send/receive UDP packets successfully. I've also tried initializing the PTP Timestamp without NetXDuo just in case there was some conflict there, but that was also unsuccessful. 

Here is my initialization code:

 /*1. Mask the Timestamp Trigger interrupt by clearing bit 12 of Interrupt
 enable register(ETH_MACIER).*/

 ETH->MACIER &= ~(ETH_MACIER_TSIE);
 PRINT_U32_BINARY(ETH->MACIER);

 // 2. Set bit 0 of Timestamp control Register (ETH_MACTSCR) to enable
 // timestamping.
 ETH->MACTSCR |= ETH_MACTSCR_TSENA;
 PRINT_U32_BINARY(ETH->MACTSCR);

 /*3. Program Subsecond increment register (ETH_MACSSIR) based on the PTP clock
 frequency. */
 ETH->MACSSIR = 4 << 16;
 PRINT_U32_BINARY(ETH->MACSSIR); 
 ETH->MACTSCR |= ETH_MACTSCR_TSCTRLSSR;
 
 /*4. If you use the Fine Correction method, program Timestamp addend register
 (ETH_MACTSAR) and set bit 5 of Timestamp control Register (ETH_MACTSCR).*/

 // skipping for now
 /* 5. Poll the Timestamp control Register (ETH_MACTSCR) until bit 5 is
 cleared.*/
 while (ETH->MACTSCR & ETH_MACTSCR_TSADDREG) {
 HAL_Delay(100);
 }
 /* 6. Program bit 1 of Timestamp control Register (ETH_MACTSCR) to select the
 Fine Update method (if required).
 //skipping for now
 7. Program System time seconds update register (ETH_MACSTSUR) and System time
 nanoseconds update register (ETH_MACSTNUR) with the appropriate time value.*/
 ETH->MACSTNUR = 0x0; //also tried 0x7fffffff
 ETH->MACSTSUR = 0x0; //also tried 0xffffffff
 
 /* 8. Set bit 2 in Timestamp control Register (ETH_MACTSCR).
 The timestamp counter starts as soon as it is initialized with the value
 written in the timestamp update registers. If one-step timestamping is
 required:*/
 
 ETH->MACTSCR |= ETH_MACTSCR_TSINIT;

 /*a) Enable one-step timestamping by programming bit 27 of the TDES3 Context
 Descriptor.
 b) Program Timestamp ingress asymmetric correction register (ETH_MACTSIACR)
 to update the correction field in PDelay_Req PTP messages.
 9. Enable the MAC receiver and transmitter for proper timestamping.*/

 while (1) {
 HAL_Delay(1000);
 PRINT_U32_BINARY(ETH->MACSTSR);
 PRINT_U32_BINARY(ETH->MACSTNR);
 }

ETH->MACSTSR and ETH->MACSTNR are always zero after this.

Thanks for any guidance you can provide! 

3 replies

February 13, 2026

I tried to do the same thing but failed.

Associate
February 25, 2026

I'd like to add an update to this. I tried exactly the same code on an STM32H723 and it works perfectly (I literally copy and pasted directly from this post into main.c for a Nucleo H723. Is PTP Timesamping on H563 broken, or am I missing something?

Visitor II
October 23, 2026

I know this is much later, but in case it is of any help to anybody, I had the same issue and found the solution (at least in my case) by looking where someone had ported flexPTP to the stm32H563 on github. He gave very detailed documentation on what he did.

Links: 

https://github.com/damiendusha/flexPTP-demo-NUCLEO-H563ZI

https://github.com/damiendusha/flexPTP-demo-NUCLEO-H563ZI/blob/main/projects/flexptp_demo_stm32h563/flexptp_threadx_netx_demo/docs/ptp_clock.md

 

If I’m understanding correctly, the regular Ethernet MAC clock input may be driven from HCLK, but the PTP clock is driven from PLL1Q, and the output of PLL1Q must be explicitly enabled. This seems to be in contrast to the STM32H743, which the person on github referenced (there was already a port for the STM32H743), and may explain why your code works on the STM32H723 and not the STM32H563. This is the command he used, which also worked for me:

__HAL_RCC_PLL1_CLKOUT_ENABLE(RCC_PLL1_DIVQ);

I also had working Ethernet without the PTP seconds and nanoseconds counters moving before I used that command.

 

There is also a more recent thread on here where someone seemed to have the same issue and the answer was to use pre-defined macro names to enable the PTP clock.

LINK:

 

I don’t know if that relies on HAL_ETH_USE_PTP being defined or not. I don’t have that defined/enabled in my code. I’m using code that I think was written before the functionality that comes with HAL_ETH_USE_PTP was added.

 

Here are a few other github repositories that may also be helpful:

https://github.com/mpthompson/stm32_ptpd

https://github.com/hasseb/stm32h7_ptpd

https://github.com/epagris/flexPTP

 

-Darren