Hi guy,
I'm using ARM STM32F103RC, Cortex M3.
when I compiler the code with this order:
//GPIO structure used to initialize port
GPIO_InitTypeDef GPIO_InitStructure;
//Enable clock on APB2 pripheral bus where button and LEDs are connected
RCC_APB2PeriphClockCmd(LEDPORTCLK | BUTTONPORTCLK, ENABLE);
is okay,
But I want to enable clock first,
the compiler give the error
main.c(28): error: #268: declaration may not appear after executable statement in block
would you like to explain to me why this happened?
Minh
Hello Minh,
in the examples that ship with the Device Family Pack for the ST32F10x devices, you can find a Blinky example that shows you how to do this. In LED.c you will find:
/*-----------------------------------------------------------------------------
* LED_Init: Initialize LED Pins
*----------------------------------------------------------------------------*/
void LED_Initialize (void) {
RCC->APB2ENR |= (1UL << 2); /* Enable GPIOA clock */
/* Configure LED (PA.5) pins as output */
GPIOA->CRL &= ~((15ul << 4*5));
GPIOA->CRL |= (( 1ul << 4*5));
}
Kind regards,
Christopher