2024-09-15 08:15 AM - last edited on 2024-09-15 09:57 AM by SofLit
Hi People,
for the since start of year i've been setting up boards with Texas C2000 , and for the past 6 months infineon tri-core processors. I may be changing jobs and it involves STM32 so i'm getting a head start. I have a STM32373C-EVAL , as i need TFT display and CAN. i have attempted to make a 'blinky ' project. Compiles fine but when it runs it hangs on the oscilator start up . Fresh install of STM32CubeIDE so used the config tool and let it do all the defaults.. The dev kit has solder bridges for crystal - they are open , but i've let it use the PLL. it wont let me
When running in debug it 'hangs' on stopping the code , its in the error handler from the system clock settings , if i comment out the error handler it runs .
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler(); // sometimes comment this out
}
/** 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_1) != HAL_OK)
{
// Error_Handler(); // wont get past this one either , but still runs ok ... why ?
}
}
Has anyone else have this grief ?
Are u supposed to do something about this... Other micros i've used you just set them up and job done ?!?!
for now i'm leaving the check commented out so i can carry on .. Some advice would be helpful though
Thanks In Advance
Solved! Go to Solution.
2024-09-17 01:00 AM
Again check the Crystal connection or simply replace it.
2024-09-15 10:11 AM
Hello @John_S and welcome to the community,
According to your Clock config and the screenshot you shared, you are using the internal clock HSI as clock source for the system not HSE (for external crystal usage):
And from your code:
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
That's strange!
Could you please attach your ioc file?
2024-09-16 07:21 AM
I don't see anything that stands out as a problem. It has been a while since I worked with an STM32F3. Are you sure that the sysclock is actually running at 36MHz when it returns with an error?
I recommend stepping through the code in the debugger to see where it is returning with an error.
Set a breakpoint on the line that calls HAL_RCC_ClockConfig() and step into that function until an error is returned. It should provide a bit more information on what is triggering the failure.
2024-09-16 07:48 AM - edited 2024-09-16 07:49 AM
@John_S wrote:The dev kit has solder bridges for crystal - they are open , but i've let it use the PLL. it wont let me
Not quite sure what you mean here?
As shown (as @SofLit said) you are using HSI - is that the case which fails?
Or are you trying to use HSE, and that's the case which fails?
To use HSE, you'll need an external crystal connected - ie, the solder bridges closed
2024-09-16 08:09 AM - edited 2024-09-16 08:16 AM
config file ..
plus
Main.c
I was going to upload the whole project but wont accept .zip ...
Project made fresh in STM32cubeMX then loaded in to cubeIDE ..
as a test i shut down IDE .. pulled the ST/link out so no power . Put plug back in (nothing ) , reloaded IDE up loaded with debug the file that was just working ... nothing ..... i'm a bit confused
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler(); // ********** Sometimes hangs here
}
/** 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_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
{
Error_Handler(); // ************ Hangs here if its going to
} // if i comment out this if statement the micro wont run but
// when i uncomment after and rebuild it will now run...
// strange as hell
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB|RCC_PERIPHCLK_USART2
|RCC_PERIPHCLK_CEC|RCC_PERIPHCLK_I2C1
|RCC_PERIPHCLK_I2C2|RCC_PERIPHCLK_ADC1
|RCC_PERIPHCLK_SDADC;
PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1;
PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_HSI;
PeriphClkInit.I2c2ClockSelection = RCC_I2C2CLKSOURCE_HSI;
PeriphClkInit.USBClockSelection = RCC_USBCLKSOURCE_PLL;
PeriphClkInit.CecClockSelection = RCC_CECCLKSOURCE_HSI;
PeriphClkInit.SdadcClockSelection = RCC_SDADCSYSCLK_DIV8;
PeriphClkInit.Adc1ClockSelection = RCC_ADC1PCLK2_DIV2;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
{
Error_Handler();
}
HAL_PWREx_EnableSDADC(PWR_SDADC_ANALOG1);
HAL_PWREx_EnableSDADC(PWR_SDADC_ANALOG2);
}
2024-09-16 08:30 AM - edited 2024-09-16 08:32 AM
Hello,
That config is different from what you posted in the first post:
The first one is using HSI and now it is using HSE. Please try to not induce us to confusions during the discussions.
Are you sure X2 crystal is mounted on its socket? Is R38 soldered?
2024-09-16 08:37 AM - edited 2024-09-16 08:38 AM
sorry i've been trying different configurations to see what works... I may have got mixed up between the two.
Yes crystal is in and r38 is in (0 ohm )
2024-09-16 08:43 AM
And if you revert o the first config: HSI (remove USB function for the moment), do you get the same behavior?
2024-09-16 08:50 AM - last edited on 2024-09-16 08:54 AM by SofLit
The code runs
but i've had to comment out the I2C1_init functions ...
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_ADC1_Init();
MX_COMP2_Init();
MX_HDMI_CEC_Init();
// MX_I2C1_Init();
// MX_I2C2_SMBUS_Init();
// MX_I2S1_Init();
MX_SDADC1_Init();
MX_SDADC2_Init();
MX_SPI3_Init();
MX_TSC_Init();
MX_USART2_UART_Init();
/* USER CODE BEGIN 2 */
2024-09-16 08:54 AM - edited 2024-09-16 08:55 AM
First, in next time please use </> button to share your code. I'm editing your post then .
Second, as with HSI is working, I'm pretty sure it's something related to the crystal. Be sure the crystal has contact in the socket. Maybe to apply a bit pressure on it with your finger.