2014-09-05 11:50 PM
Dear forum members,
I hope you can help solving a mystery. I stumbled upon these cute stm32f030f4 µCs and built minimalistic boards with it. No external oscillator used, thus pins PF0 and PF1 should be useable as GPIOs. I tried several things already. Current state is explicitly disabling HSE, deinit the clock system and setting it up correctly:// ---- Setup PLL for 48 MHz :) ----
RCC_HSEConfig(RCC_HSE_OFF);
RCC_DeInit();
RCC_PLLCmd(DISABLE);
RCC_PLLConfig(RCC_PLLSource_HSI, RCC_PLLMul_12);
// Flash: 1 WaitState for 24MHz < SysCLK < 48 MHz
FLASH_SetLatency(FLASH_Latency_1);
FLASH_PrefetchBufferCmd(ENABLE);
// Set ADC clock to internal 14MHz HSI source
RCC_HSI14Cmd(ENABLE);
RCC_HSI14ADCRequestCmd(ENABLE);
// 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 :) ----
It doesn't make a difference whether the HSE-Disable is before or after deinit. I also modified CMSIS/stm32f0xx.c -> SysCLKinit so HSE was disabled by all means, but that didn't help either.
Further pin setup:
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOF, ENABLE);
// LED: Configure PF0 and PF1 in output pushpull mode
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOF, &GPIO_InitStructure);
// and in main loop:
GPIOF->BRR = (GPIO_Pin_0);
// Set PF0 to GND
uint32_t my_counter = 0;
int
step = 10;
uint32_t border=10000;
while
(1) {
my_counter += step;
if
((my_counter == border) | (my_counter==0)) {
step = -step;
}
GPIOF->BSRR = GPIO_Pin_1;
// Set PF1 HIGH (LED on)
Delay(my_counter);
GPIOF->BRR = GPIO_Pin_1;
// Set PF1 to GND (LED off)
Delay(border-my_counter);
}
Setup for the pins as Alternative Function, AF0 or AF1, didn't make a difference.
I'm running out of ideas what else to do to get all 15 GPIOs working. Maybe someone already managed that and has a pointer to the solution.
Thanks for taking the time to read through all this! :)
#pf1 #gpio #stm32f030 #pf0
2014-09-06 07:21 AM
Problem solved: I need to go back to the soldering station.
Just replaced the board with another one I built and it immediatly works, even without calling the ''RCC_HSECmd''; RCC_DeInit() suffices.Great, now I can use 15 IOs! :)