2014-09-30 08:07 AM
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 #solved2014-10-01 12:53 AM
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? JW2014-10-01 07:20 AM
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.2014-10-01 08:36 AM
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? JW2014-10-01 11:27 AM
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!2014-10-02 12:15 AM
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