cancel
Showing results for 
Search instead for 
Did you mean: 

PTP PPS output on stm32f407

renato1
Associate II
Posted on September 30, 2014 at 17:07

Hello

I have a STM32F407ZGT6, silicon revision Z, and I'm trying to generate a 1PPS output (Pulse Per Second) on pin PG8, using the PTP. The PTP is working fine, correctly timestamping the PTP packets. 

In the reference manual (RM0090, rev. 7), there is a section called ''PTP pulse-per-second output signal'', and it says:

''The PPS output is enabled through bits 11 and 10 in the TIM2 option register (TIM2_OR).''

However, in the description of the TIM2_OR, there isn't an option to activate the PTP PPS:

Bits 11:10 ITR1_RMP: Internal trigger 1 remap

    Set and cleared by software.

    00: TIM8_TRGOUT

    01: PTP trigger output is connected to TIM2_ITR1

    10: OTG FS SOF is connected to the TIM2_ITR1 input

    11: OTG HS SOF is connected to the TIM2_ITR1 input

but these bits only control the TIM2_ITR1.

Still, I tried to set the bits to 00, 01, 10 and 11, without success. The code I'm using is:

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOG, ENABLE);

// Configure pin PG8 = PTP PPS Out

GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_8;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF;

GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_NOPULL;

GPIO_Init(GPIOG, &GPIO_InitStructure);

GPIO_PinAFConfig(GPIOG, GPIO_Pin_8, GPIO_AF_ETH);

RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);

TIM_DeInit(TIM2);

TIM_RemapConfig(TIM2, TIM2_ETH_PTP);

Can anyone help me?

#stm32f4-ptp-pps #solved
5 REPLIES 5
Posted on October 01, 2014 at 09:53

I don't use this facility, so just a couple of blind and possibly stupid questions:

- what happens if you *don't* set the TIM2_OR remap

- can you try pin PB5 instead of PG8?

JW

renato1
Associate II
Posted on October 01, 2014 at 16:20

Thanks for the suggestions

I've tried not setting the TIM2_OR and using PB5 instead of PG8, but it didn't work.... The pins just stay at 0V.
Posted on October 01, 2014 at 17:36

Humm.

And what happens if you set the redirect from ET_PPS in TIM2_OR, set TIM2 to External Clock Mode 1 with ITR1 as the clock (in TIM2->SMCR, SMS = 111, TS = 001) and enable the timer (TIM2->ARR = 0xFFFF, TIM2->CR1.CEN=1), will TIM2 start counting?

JW

renato1
Associate II
Posted on October 01, 2014 at 20:27

Thanks again, JW 

No... the ITR1 is connected to the PTP Trigger Output, that is an alarm that is set high when the PTP time is greater than a programmable target time.

But, I found out what the problem was.

I used  GPIO_Pin_8  instead of  GPIO_PinSource8  in the GPIO_PinAFConfig...

The correct code is:

GPIO_PinAFConfig(GPIOG, GPIO_PinSource8, GPIO_AF_ETH);

And it's not necessary to change the TIM2_OR.

Now it's working!
Posted on October 02, 2014 at 09:15

Glad you got it working.

> No... the ITR1 is connected to the PTP Trigger Output, that is an alarm that is set high when

> the PTP time is greater than a programmable target time.

Ah, I see.

Then the line

''The PPS output is enabled through bits 11 and 10 in the TIM2 option register (TIM2_OR).''

in UM0090 is simply not true. Not the first error in the UM... :(

> But, I found out what the problem was.

> I used  GPIO_Pin_8  instead of  GPIO_PinSource8  in the GPIO_PinAFConfig...

That's a deserved punishment for using the ''library'' instead of direct register access.. 😉

Jan