My leds keep flashing, so the MCU keeps crashing and restarting.
Not sure how your code works so not much can be read from the fact that "the led keep flashing"
After programming the MCU also disconnects from programmer, picture added.
Typically from the swd pins being used by the code.
The only problem that i had, was that i couldn't use the flash functions.
I've added #include "stm32f0xx_flash.h", with no result. My compiler does not find the routines in the corresponding .c file.
Include the .c files in your project and have the .h files in the include path.
If I were you, I would post a minimalist but complete piece of code so that others know what you are talking about.
As to wait state, I ran a stm32f030f up to 50+Mhz on 0 wait state so it is fairly tolerant.
Okay, have had a busy weekend with another project. Sorry for the late feedback.
Code for main.cpp that i used:
#include <stdio.h>
#include "stm32f0xx.h"
#include "stm32f0xx_flash.h"
void delay(long int delaytime){
for(long int i=0; i<(delaytime*10000000);i++){
}
}
int
main(int argc, char* argv[])
{
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
GPIO_InitTypeDef gis;
gis.GPIO_Mode = GPIO_Mode_OUT;
gis.GPIO_OType = GPIO_OType_PP;
gis.GPIO_Pin = GPIO_Pin_12;
gis.GPIO_PuPd = GPIO_PuPd_NOPULL;
gis.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA,&gis);
// ---- Setup PLL for 48 MHz :) ----
RCC_DeInit();
RCC_PLLCmd(DISABLE);
RCC_PLLConfig(RCC_PLLSource_HSI, RCC_PLLMul_2);
// Flash: 1 WaitState for 24MHz < SysCLK < 48 MHz
//FLASH_SetLatency(FLASH_Latency_1);
//FLASH_PrefetchBufferCmd(ENABLE);
// Set ADC clock to internal HSI 14MHz
RCC_ADCCLKConfig(RCC_ADCCLK_HSI14);
// and turn the PLL back on again
RCC_PLLCmd(ENABLE);
// set PLL as system clock source
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
// ---- End of Setup PLL for 48 MHz :) ----
// Infinite loop
while (1)
{
delay(100);
GPIOA->BSRR = GPIO_Pin_12;
delay(100);
GPIOA->BRR = GPIO_Pin_12;
}
return 0;
}
So my IDE is eclipse with gcc-arm-none-eabi-4_8-2014q2.
I'm using the eclipse wizard that sets up a project in C++ with all the necessary includes and .c-files.
Reference: GNU ARM C/C++ STM32Fx Project Templates 2.1.1.201404240550 ilg.gnuarmeclipse.templates.stm.feature.group Liviu Ionescu
I've stripped everything from the code and just using the linked main.cpp file as above.
The chip is the STM32F051C8T6 on a custom board, its the LQFP48 board.
I'm using the HSE pins for something else, assuming i can get the HSI to work.. (That was the plan though..)
Connected via GDB and the STLINK utility from texane (yep, on OS X).
Have had other projects running without any problem, but since i made this custom board with HSI, these problems.
STLink V2 genuine from ST, so no fake. Genuine STM32F0's ordered from mouser. (So i'm using no fake, hate fake in the development fase.)
I've stepped through my code and find that this gives me the error:
void RCC_PLLCmd(FunctionalState NewState)
{
/* Check the parameters */
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
RCC->CR |= RCC_CR_PLLON;
}
else
{
RCC->CR &= ~RCC_CR_PLLON;
}
}
I step through my code, everything goes well, until my PLL-bit gets set and then i lose everything. ->>
RCC->CR |= RCC_CR_PLLON;When i was talking about the led, i let an LED light up right before the PLL configuration, and the led flashes very dim.
What i think that happens is that it just resets and goes into an infinite loop..
I'm having the necessary decoupling caps on the bottom side of the PCB right below the pins with via's.
0402 caps with 1 tantalum as per datasheet. (did my research).
I'm really scratching my head on this one.
When i'm going into the system_stm32f0xx.c file, i see that the SetSysClock routine sets the HSE bit on, waits for the HSE to get ready and then bails out.
I've found adjusted SetSysClock routines that incorporate compiler directives to adjust for the HSI in the first go, but i guess doing this in main() does the same thing..
I hope this is enough info..