2016-09-27 07:36 PM
I try to run the following program on KEIL MDK 5.0:
&sharpinclude ''stm32f0xx.h''int main(void){ volatile unsigned int i=0; RCC -> AHBENR |= (i<<19); GPIOC ->MODER |= (i<<16); // mode GPIOC ->ODR |= (i<<8); // output data is ON while (1) { for (i=0; i<1000000; i++) GPIOC ->ODR |= (i<<8); // output data is ON for (i=0; i<1000000; i++) GPIOC ->ODR &= (i<<8); // output data is OFF } }From some reason I don't see the BLUE LED blinking.Anyone know why?Thanks,Miri #stm32f051-stm32-stm32f02016-09-29 09:16 AM
I tried this as well:
GPIOC ->ODR |= 1;
GPIOC ->ODR |= 0;
But nothing happen with the leds.2016-09-29 09:27 AM
GPIOC ->ODR |= 1;
GPIOC ->ODR |= 0;Is PC0 connected to an LED, and configured as an output?Or'ing something with zero isn't going to do anything useful.GPIOC ->ODR |= 256; // PC8 SetGPIOC ->ODR &= ~256; // PC8 Clear
2016-09-29 09:33 AM
2016-09-29 09:40 AM
GPIOC ->MODER |= (1<<
16
); // mode Output
or
GPIOC ->MODER |= 256
; // mode Output
2016-09-29 09:41 AM
Perhaps you could use the debugger and step through the code whilst looking at the Peripheral Registers in the viewer?
2016-09-29 09:49 AM
What is a good configuration of PC8 to output?
GPIOC ->MODER |= (1<<16); // mode Output
or
GPIOC ->MODER |= 256; // mode OutputIf you look at the Reference Manual, it indicates that there are two bits for each pin, which is why it shifts the 1 by 16 and not 8.If you choose to program at the register level you're going to have to be very familiar with the manual and the descriptions of the registers at a bit level. Consider using the Standard Peripheral Library (SPL)You might need some additional delay between enabling the GPIOC clock, and writing to the peripheral.
2016-09-29 11:04 AM
Hi miri,
To start developping STM32 application you can use either standard peripherals library (you can download STM32F0xx standard peripheral library from this ) or you can use the Hal library called STM32Cube ( you can download STM32CubeF0 from this ).For GPIO toggling follow these path:* In standard peripherals library: STM32F0xx_StdPeriph_Lib_V1.5.0\Projects\STM32F0xx_StdPeriph_Examples\GPIO\GPIO_IOToggle* In STM32CubeF0: projects are classified per board : for example for the STM32F030R8-Nucleo follow this example path:STM32Cube_FW_F0_V1.6.0\Projects\STM32F030R8-Nucleo\Examples\GPIO\GPIO_IOToggle-Hannibal-