cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L151VDT: Problem increasing Vcore.

marten23
Associate
Posted on September 16, 2015 at 18:07

Dear,

Using the STM32L151VDT, I have a problem increasing Vcore with the voltage regulator to range 1 (1.8V). This is needed to later have a system clock of 32MHz. It seems that waiting till PRW_CSR.VOSF equals 0 is not enough. Depending of the code alignment the first instructions after the wait loop are not executed. And this only when prefetch is enabled. When the alignment is changed by removing the first asm(''nop''); it is ok. I am building in IAR without optimization, using the latest Cube libs (v1.3.0). main.c:

#include ''stm32l1xx_hal.h''
uint32_t test1 = 1;
uint32_t test2 = 1;
uint32_t test3 = 1;
uint32_t test4 = 1;
int main(void)
{
/* Set alignment correct to see the problem */
asm(''nop'');
__HAL_FLASH_PREFETCH_BUFFER_ENABLE(); /* This is normally part of HAL_Init() */
__HAL_RCC_PWR_CLK_ENABLE();
/* Just to be sure : see RCC errata 2.7.1 */
asm(''nop'');
asm(''nop'');
while (__HAL_PWR_GET_FLAG(PWR_FLAG_VOS) != RESET) {}
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
while (__HAL_PWR_GET_FLAG(PWR_FLAG_VOS) != RESET) {}
test1++; /* This will not be completely executed ! and will NOT be 2 ! */
test2++; /* This will be 2 */
test3++; /* This will be 2 */
test4++; /* This will be 2 */
}

system_stm32l1xx.c (From Cube):

void SystemInit (void)
{
/*!< 
Set
MSION bit */
RCC->CR |= (uint32_t)0x00000100;
/*!< 
Reset
SW[1:0], HPRE[3:0], PPRE1[2:0], PPRE2[2:0], MCOSEL[2:0] and MCOPRE[2:0] bits */
RCC->CFGR &= (uint32_t)0x88FFC00C;
/*!< 
Reset
HSION, HSEON, CSSON and PLLON bits */
RCC->CR &= (uint32_t)0xEEFEFFFE;
/*!< 
Reset
HSEBYP bit */
RCC->CR &= (uint32_t)0xFFFBFFFF;
/*!< 
Reset
PLLSRC, PLLMUL[3:0] and PLLDIV[1:0] bits */
RCC->CFGR &= (uint32_t)0xFF02FFFF;
/*!< 
Disable
all interrupts */
RCC->CIR = 0x00000000;
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */
}

I can ''fix'' it by inserting 4 nop instructions after the second wait loop:

asm(''nop'');
asm(''nop'');
asm(''nop'');
asm(''nop'');

What could be the problem ? Regards, Marten #stm32l151
0 REPLIES 0