cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G4 TCXO

CrazyChel
Associate III
Please let me know if there are any hardware or sofware specifics for connecting TCXO to the STM32G474 series? What should pay special attention to?
I use FT2MN at 40 MHz. Its output was connected through a 10 pF capacitor and a 220 Ohm resistor, in series, to PF0 RCC_OSC_IN.
I'm running CubeIDE 1.16.0.
Unfortunately this doesn't work, I'll use a primitive for testing:

 

  while (1)
  {
  HAL_GPIO_TogglePin(GPIOC, LED_G_Pin);
  HAL_Delay(100);
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }

 

 
When power is supplied, the LED_G lights up constantly. After pressing the reset button, it turns off and does not turn on again. If I turn the power off and on again, everything repeats itself.
 
When I change the configuration to the built-in RC generator. The LED_G flashes as specified by the program, the reset button works correctly.
 
I tried to see what happens at the input PF0 with my DSO2D15 oscilloscope, the declared band is 150 MHz, with the original probe in the 1:10 mode. I am not sure about the reliability of the results, especially regarding the amplitude. There I see a truncated sine wave that goes negative to 200 mV and positive to 220 mV. Accordingly, the full amplitude is 420 mV. Directly at the output of the TCXO, the amplitude is 1.2 V, and it almost does not go to negative. I didn't see a significant DC component there.
25 REPLIES 25

@CrazyChel wrote:

 my oscilloscope overestimated the value by 2 times.


Was it set to x2 ? Or was the probe set to x2?

(yes, x10 is more usual, but ...)

I checked it, the problem is the accuracy of the oscilloscope at 40MHz

Many thanks for you support!

I make it. 

void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

  /** Configure the main internal regulator output voltage
  */
  HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1_BOOST);

  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV4;
  RCC_OscInitStruct.PLL.PLLN = 34;
  RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
  RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
  RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
	  HAL_GPIO_WritePin(GPIOC, LED_R_Pin, GPIO_PIN_SET);
    Error_Handler();
  }

  /** Initializes the CPU, AHB and APB buses clocks
  */
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
  {
    Error_Handler();
  }
}

In the debugger HAL_Init(); passes, I get to the line (24 in this code) HAL_GPIO_WritePin(GPIOC, LED_R_Pin, GPIO_PIN_SET); after which all the buttons for the next steps are grayed out. And LED_R_Pin remains at zero, I don't see even a short pulse there.

I also soldered a capacitor 8.2 pF to the connection point of the generator and controller. Shorting the other side of the capacitor to ground does not change anything at all.


I ported HAL_GPIO_WritePin(GPIOC, LED_R_Pin, GPIO_PIN_SET); directly into the void Error_Handler(void)

void Error_Handler(void)
{
  /* USER CODE BEGIN Error_Handler_Debug */

  /* User can add his own implementation to report the HAL error return state */
  __disable_irq();
  while (1)
  {
	  HAL_GPIO_WritePin(GPIOC, LED_R_Pin, GPIO_PIN_SET);
  }
  /* USER CODE END Error_Handler_Debug */
}



I see that I get there from a function void SystemClock_Config(void). But unfortunately it doesn't give me a clue how to solve the problem. The only thing that comes to mind is that the generator output voltage should be higher.


@CrazyChel wrote:

I see that I get there from a function void SystemClock_Config(void)


So step into that function, and see where the error occurs ...

If there are experts here on board tracing, please tell me whether such a board layout can affect the operation of the generator (at a frequency of 40 MHz)? Underestimate its amplitude. Textolite 1.6 mm, red upper layer, blue lower layer. The filling of the polygons of the lower layer is continuous.TCXO routing.png

Here I get into an error handler.

  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
	Error_Handler();
  }

So, again, step into that function; see where it goes wrong.

My post from 2024-09-20 08:15 AM I get to line 25 from it I get to the error handler function itself. There is a loop.


@CrazyChel wrote:

I use FT2MN at 40 MHz.


So this: https://abracon.com/datasheets/FT2MN.pdf 

 


@CrazyChel wrote:

the amplitude at the output of the generator is no more than 0.6 V. According to the data sheet on the STM, the input of PF0 should be much higher.


The datasheet says it could be 0.8V - so not necessarily much higher.

@Peter BENSCH has already given the input requirements of the STM32 - and that certainly is very much higher than even 0.8V !

The TCXO datasheet also says: 

AndrewNeil_0-1726848166679.png

But Peter has already said that a capacitor link will not work with the STM32.

It sounds like you have selected the wrong part for this application.

Perhaps you should discuss your requirement with Fox and find what they would recommend here:

https://abracon.com/support/tech-support-form