2018-04-27 06:43 AM
I'm running into an issue where the program will time out on
while(READ_BIT(RCC->CR, RCC_CR_PLLRDY) == RESET)
in stm32l4xx_hal_rcc.c:839 depending on how much code compiled in main.c. The program will execute fine with minimal code, but adding code in main(), even code not yet executed, will cause the time out.
Code was generated using STM32CubeMX 4.25.0, STM32Cube V1.0. IDE is System Workbench for STM32, fr.ac6.feature.ide version is 2.4.0.201801121207. Target is Nucleo-L452RE-P. Tested on multiple boards.
To reproduce:
/* USER CODE BEGIN 3 */
QSPI_CommandTypeDef sCommand; uint8_t reg; volatile uint8_t err = 0;/* Read status register */
sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE; sCommand.Instruction = 0x00; sCommand.AddressMode = QSPI_ADDRESS_NONE; sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE; sCommand.DataMode = QSPI_DATA_1_LINE; sCommand.DummyCycles = 0; sCommand.NbData = 1; sCommand.DdrMode = QSPI_DDR_MODE_DISABLE; sCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY; sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;while (1) {
if (HAL_QSPI_Command(&hqspi, &sCommand, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
{ err = 1; }reg = 0xAA;
if (HAL_QSPI_Transmit(&hqspi, ®, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) { err = 1; }reg = 0x55;
if (HAL_QSPI_Transmit(&hqspi, ®, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) { err = 1; }// reg = 0xBB;
// if (HAL_QSPI_Transmit(&hqspi, ®, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {// err = 1;// } } } /* USER CODE END 3 */Add break point to stm32l4xx_hal_rcc.c:839, return HAL_TIMEOUT;
In Project Properties, enable Parallel Build (Project Properties->C/C++ Build->Benavior: Enable parallel build (checked))
Debug the project, and let it run. It will stop at the break point in main.
// reg = 0xBB;
// if (HAL_QSPI_Transmit(&hqspi, ®, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
// err = 1;
// }
toreg = 0xBB;
if (HAL_QSPI_Transmit(&hqspi, ®, HAL_QPSI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) { err = 1; }stm32l4xx_hal_rcc
.cThe breakpoint in
stm32l4xx_hal_rcc.c hits before the uncommented code even executes. What is going on?
2018-04-27 07:30 AM
Does seem odd, would probably look at the .MAP, the RAM usage and .LST file of the code the processor is running. Look where it is putting the stack.
Generally here I get the USART/VCP running, along with the Hard Fault Handler, and I can instrument the code and see whats happening.
You perhaps want to dump the RCC registers, and track the execution without breakpoints. Instead of commenting out code put an 'if' around it for a variable that can be set either way.
Perhaps you can try a professional tool chain like Keil or IAR? Got a lot more confidence in the code generation, linker and debuggers there.
2018-05-22 06:14 AM
Seems to be fixed in Cube 4.25.1 update.
2018-05-22 10:34 AM
They supposedly fixed a problem on the L4 with respect to the PLLM setting, but not sure it is size dependent.
Local variables can have random data from the stack.