0

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, 894784853);    // 2^63 / 20 / 480M
  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, 0x01);
  WRITE_REG(heth->Instance->MACSTNUR, 0x02);
  SET_BIT(heth->Instance->MACTSCR, ETH_MACTSCR_TSINIT); // If one-step timestamping is required follow reference manual
  // 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.

enter image description here

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

enter image description here

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

ierturk
  • 452
  • 6
  • 22
  • I was interested to hear which clock source you ended up using for the 1588 timestamping block. I am tentatively hoping to input a clock to OSC_IN and then select HSE which generates sys_clk and then use sys_clk to generate rcc_hclk1. Also is the clock that you use variable? i.e. changed on the fly? – cpeng Apr 01 '22 at 05:13
  • we use ptp clock within ETH_MAC – ierturk Apr 16 '22 at 09:45
  • Thanks @iertuk for getting back to me. Sorry when you said ptp clock it wasn't too clear to me. Referring to the image that you had in your question, I was wondering which of the clock(s) were you sourcing to the ethernet MAC? – cpeng Apr 28 '22 at 23:46

1 Answers1

0

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. so the value has to be shifted by 16.

enter image description here

Everything runs as expected when changed the value as follow.

WRITE_REG(heth->Instance->MACSSIR, ((uint32_t)20)<<16);
ierturk
  • 452
  • 6
  • 22