cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L071 peripherals problem

FYASA.1
Associate II

We designed a very basic circuit to test an idea. We chose STM32L071K8U6. Because, It met our needs well.

Schema

0693W000008zaeGQAQ.jpg 

MCU Pinmap

0693W000008zaeQQAQ.pngMCU Clock config in STM32CubeIde

0693W000008zaf9QAA.png 

If you look at the clock settings, this processor does not use an external resonator. It currently provides a builtin 16mhz internal oscillator.

We can upload programs to the processor via SWD. However, we cannot use peripherals.

The program often freezes on lines like MX_USART1_UART_Init () or MX_I2C3_Init ().

It seems like a clock setting problem but we couldn't find a solution.

What are we doing wrong?

9 REPLIES 9
Lgliu
Associate II

You can try to set clock above 16M​.

FYASA.1
Associate II

Hi, thank you for the answer.

When I set the clock to 32Mhz (max) or 24 Mhz. It gets stuck on in SystemClock_Config

Exactly below lines in generated SystemClock_Config function.

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)

Hi, thank you for the answer.

When I set the clock to 32Mhz (max) or 24 Mhz. It gets stuck on in SystemClock_Config

Exactly below lines in generated SystemClock_Config function.

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)

Lgliu
Associate II

​Are you generating code with stm32cub? Try to check conflict or make new project to test uart alone. I used this chip, if i set clock below 16M, uart can't work well.

FYASA.1
Associate II

Yes, Im generating code with stm32CubMx which inside of stm32cubeide.

I've tried to create many projects with many clock options to test uart, i2c alone. No luck.

Meanwhile, inside stm32l0xx_it.c the SysTick_Handler does not get called.

Could this be the source of the problem?

It's really weird. Can only work at your initial clock frequency 4.194M??

I also tried increase speed up to 32 Mhz.

0693W000008zhC9QAI.png 

But, unfortunately code stuck below line in SystemClock_Config()

if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)

I didn't write any custom code yet.

All very odd

FLASH_LATENCY_1 should be adequate for 32 MHz at 3.3V

Is the part Hard Faulting?

VDDIO2 is only for PA11/PA12 as I recall

Circuit looks simple enough, resolution if image is poor

I'd start with the supplies, probably add some bulk capacitance near-in

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I mean,you can try to make a new project to confirm the function SystemClock_Config can only work at 4.194M? Maybe it's not the frequency of modification.