cancel
Showing results for 
Search instead for 
Did you mean: 

IEEE 1588 PTP Clock Source in STM32H743

ierturk
Associate III

Hi,

I'm trying to get PTP timestamp on STM32H743 Nucleo board. There is no proble with LwIP and ethernet driver so far except for PTP. I followed the instruction( 58.9.7 Programming guidelines for IEEE 1588 timestamping) on reference manual (RM0433) as follow.

CLEAR_BIT(heth->Instance->MACIER, ETH_MACIER_TSIE);
  SET_BIT(heth->Instance->MACTSCR, ETH_MACTSCR_TSENA);
  WRITE_REG(heth->Instance->MACSSIR, 20);
  WRITE_REG(heth->Instance->MACTSAR, 0xcc);
  SET_BIT(heth->Instance->MACTSCR, ETH_MACTSCR_TSADDREG);
  while(READ_BIT(heth->Instance->MACTSCR, ETH_MACTSCR_TSADDREG));
  SET_BIT(heth->Instance->MACTSCR, ETH_MACTSCR_TSCFUPDT);
  WRITE_REG(heth->Instance->MACSTSUR, 0x00);
  WRITE_REG(heth->Instance->MACSTNUR, 0x00);
  SET_BIT(heth->Instance->MACTSCR, ETH_MACTSCR_TSINIT)
  // TODO: configure pps

However, System time seconds register (ETH_MACSTSR) does not count and just loaded initial value in System time seconds update register (ETH_MACSTSUR). In reference maual there is no clear information about clock source for PTP. In STM32F7, there is a clock path for PTP as in image below in CubeMX clock configuraton page.

0693W000000VtlEQAS.png

However there no clock path for PTP in STM32H7 as in image below.

0693W000000VtlOQAS.png

Am I missing something about to get system time from the registers ETH_MACSTSR and ETH_MACSTNR ?

Thanks in advance.

ierturk

1 ACCEPTED SOLUTION

Accepted Solutions
ierturk
Associate III

The problem comes from the Sub-second increment register (ETH_MACSSIR). The value to be incremented is stored in high word of the register as in the image below.

0693W000000W2siQAC.png

Everything runs as expected when changed the value as follow.

WRITE_REG(heth->Instance->MACSSIR, ((uint32_t)20)<<16);

View solution in original post

1 REPLY 1
ierturk
Associate III

The problem comes from the Sub-second increment register (ETH_MACSSIR). The value to be incremented is stored in high word of the register as in the image below.

0693W000000W2siQAC.png

Everything runs as expected when changed the value as follow.

WRITE_REG(heth->Instance->MACSSIR, ((uint32_t)20)<<16);