Hi,
I've just soldered a second PCB with a STM32F429ZIT6. The first PCB runs perfectly, so the code seems correct.
I compile, and debug the code. The code is loaded correctly because there is any complain from Keil.
I start debug, but when I configure the clock, the system crash.
The code starts with:
int main(void) { GPIO_InitTypeDef GPIO_InitStruct; /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); [...]
And when the syestem goes to SystemClock_Config
void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct; RCC_ClkInitTypeDef RCC_ClkInitStruct; RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; __HAL_RCC_PWR_CLK_ENABLE(); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLM = 8; RCC_OscInitStruct.PLL.PLLN = 336; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; RCC_OscInitStruct.PLL.PLLQ = 7; HAL_RCC_OscConfig(&RCC_OscInitStruct); 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_DIV4; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5); [...]
Then in HAL_RCC_ClockConfig:
HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency) { uint32_t tickstart = 0U; /* Check the parameters */ assert_param(IS_RCC_CLOCKTYPE(RCC_ClkInitStruct->ClockType)); assert_param(IS_FLASH_LATENCY(FLatency)); /* To correctly read data from FLASH memory, the number of wait states (LATENCY) must be correctly programmed according to the frequency of the CPU clock (HCLK) and the supply voltage of the device. */ /* Increasing the number of wait states because of higher CPU frequency */ if(FLatency > (FLASH->ACR & FLASH_ACR_LATENCY)) { /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */ __HAL_FLASH_SET_LATENCY(FLatency); /* Check that the new number of wait states is taken into account to access the Flash memory by reading the FLASH_ACR register */ if((FLASH->ACR & FLASH_ACR_LATENCY) != FLatency) { return HAL_ERROR; } } /*-------------------------- HCLK Configuration --------------------------*/ if(((RCC_ClkInitStruct->ClockType) & RCC_CLOCKTYPE_HCLK) == RCC_CLOCKTYPE_HCLK) { assert_param(IS_RCC_HCLK(RCC_ClkInitStruct->AHBCLKDivider)); MODIFY_REG(RCC->CFGR, RCC_CFGR_HPRE, RCC_ClkInitStruct->AHBCLKDivider); } /*------------------------- SYSCLK Configuration ---------------------------*/ if(((RCC_ClkInitStruct->ClockType) & RCC_CLOCKTYPE_SYSCLK) == RCC_CLOCKTYPE_SYSCLK) { assert_param(IS_RCC_SYSCLKSOURCE(RCC_ClkInitStruct->SYSCLKSource)); /* HSE is selected as System Clock Source */ if(RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_HSE) { /* Check the HSE ready flag */ if(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) == RESET) { return HAL_ERROR; } } /* PLL is selected as System Clock Source */ else if((RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_PLLCLK) || (RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_PLLRCLK)) { /* Check the PLL ready flag */ if(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLRDY) == RESET) { return HAL_ERROR; } } /* HSI is selected as System Clock Source */ else { /* Check the HSI ready flag */ if(__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) == RESET) { return HAL_ERROR; } } __HAL_RCC_SYSCLK_CONFIG(RCC_ClkInitStruct->SYSCLKSource); [...]
Arrives in HAL_RCC_SYSCLK_CONFIG and crash!!!
You can see exactly the moment which it crashes.
[IMG]i68.tinypic.com/2v8ml5k.png[/IMG] i68.tinypic.com/2v8ml5k.png
I've reviewed the solders but I don't find the throuble. Can anybody help me?
Thanks in advance
>>Can anybody help me?
Only you have your board.
You would want to double check voltages and clocks. Perform basic board bring-up validation.
Confirm 1.25V on VCAP pins Confirm assorted clocks via MCO pin Make sure external clock is 8MHz, and clocking Try using the 16 MHz HSI with the PLL to get 168MHz, confirm that works
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; RCC_OscInitStruct.PLL.PLLM = 16; RCC_OscInitStruct.PLL.PLLN = 336; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; RCC_OscInitStruct.PLL.PLLQ = 7; HAL_RCC_OscConfig(&RCC_OscInitStruct);
Hi Westonsupermare Pier,
Thank you very much for your attention.
I've just doing yours proposals tests, and the results are:
Confirm 1.25V on VCAP pins 1) the mean voltage is 1.69v in both pins (you can see both pins in the images, so I understand it is ok. i.imgsafe.org/f64154c981.jpg i.imgsafe.org/f64188438c.jpg
Confirm assorted clocks via MCO pin 2) I check the MCO pin (pins 99 and 100) and the voltage is 0v. Is it wrong?
Make sure external clock is 8MHz, and clocking 3) The external clock is 25MHz
How I can configure MCO pins works? they works by default? sorry, but I've never worked with this microprocesor before and I'm lost.
Thanks
You were told to make sure the External clock was 8MHz for a reason - because if it was not, then your configuration was not correct.
IF the external clock is 25MHz, you are trying to bump the chip to 525MHz. The parameters you are using are for an 8MHz clock. The easiest fix is the make PLLM = 25 instead of 8. I cannot say that is your problem, but I can say if you had a 25MHz external clock and set the Main PLL the way it is, what you are seeing is what I would expect.
If that still fails you really should try with the internal 16MHz HSI. First without the PLL (which you essentially have already tested because your code failed where it did) then with the PLL. As was already posted change PLLM to 16 instead of 8 for a 16MHz clock.
Wow, I'm so sorry.
I've inherited this code from my old colleage which he currently isn't in my company, so I soldered this new board according to the schematic, but I've just seen that in the first board he change the crystal without tell me anything.
I trust with his code and the schematic.
So, I change the crystall to 8MHz and it works.
Thank you very much Robert and Pier.