2025-03-21 3:14 AM
Good day,
I've been working on getting an external adc on the nucleo H755ziq to work at max speed. The adc can reach up to 1 million samples a second with a clock cycle time of 10ns. Problem is that it's only seeming to go at a speed of 60ns per clock cycle. Spi is set at 200mhz with a /2 prescaler on an external 48mhz crystal. Any idea why it's getting this 60ns speed instead of 10ns? Ive set the GPIO for spi to very high speed as well encase that was the issue.
2025-03-21 3:22 AM
Hi,
not clear : you have an external adc at 1 Msps . Why ( internal 16b ADC can do this also ) ?
+
SPI at 100Mbit set (bit high...for 1 Ms conversion rate - or not ?) - but runs 6x slower - right ?
Did you check with MCO , the internal clock is what you expect ?
2025-03-21 3:39 AM
It's an external ADC bc of a project Im working on that I can't specify more about. It's a custom ADC is as much as I can say. The important part is that, when checking the speed in the code, it shows the correct speeds of 100mhz for the spi (simply checked with HAL_RCC_GetPCLK2Freq()). meanwhile the logic analyser shows the speed of 60ns per clock cycle which suggests a 16.667mhz speed instead. It's like a 6x prescaler is added on or something.
2025-03-21 4:27 AM - edited 2025-03-21 4:34 AM
Ok,
so what is set as prescaler for this spi ?
see in your main: (example on spi4)
static void MX_SPI4_Init(void)
{
/* USER CODE BEGIN SPI4_Init 0 */
/* USER CODE END SPI4_Init 0 */
/* USER CODE BEGIN SPI4_Init 1 */
/* USER CODE END SPI4_Init 1 */
/* SPI4 parameter configuration*/
hspi4.Instance = SPI4;
hspi4.Init.Mode = SPI_MODE_MASTER;
hspi4.Init.Direction = SPI_DIRECTION_2LINES;
hspi4.Init.DataSize = SPI_DATASIZE_8BIT;
hspi4.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi4.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi4.Init.NSS = SPI_NSS_SOFT;
hspi4.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
hspi4.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi4.Init.TIMode = SPI_TIMODE_DISABLE;
...here prescaler /2 , so look, whats in your xx.init .
+
If this looks good, check with a scope on MCO , the internal clock is really what you expect !
2025-03-21 4:52 AM
Hello @Igneous
Could you share with us your system clock config please?
2025-03-21 5:13 AM
> nucleo H755ziq
> external 48mhz crystal
This board doesn't have a 48 MHz crystal. It does have a 8 MHz clock source from the ST-Link chip which is connected by default. Note that 8/48 = 0.1666 so maybe your clock source is just wrong (HSE_VALUE).
2025-03-21 5:16 AM
this should do for that
2025-03-21 5:20 AM
The 48mhz crystal is custom fitted to the board.
2025-03-21 5:39 AM
Did you also modify the solder bridges appropriately so that it's connected?
Toggle an LED with HAL_Delay(1000) between to ensure clock is correct if you can't verify on a scope.
2025-03-21 5:52 AM
You are indeed correct that it seems to be using the 8mhz crystal. Changing the HSE value to 48mhz does not seem to have change the actual speed. It's running at 8mhz. Ill have to talk to the person who soddered it on to ask how or why Im unable to change the frequency of it. Kind of odd. I can though funnily enough use the 8mhz to reach my 10ns goal, so it's whatever I suppose