2016-04-10 10:46 AM
Hi,
I've got problem with code. LED on my board STM32F411RE don't turn off when I'm using cmsis library but in HAL or StdPeriph it works. &sharpinclude ''stm32f4xx.h'' &sharpinclude ''core_cm4.h'' int main(void) { //configure output RCC->AHB1ENR = RCC_AHB1ENR_GPIOAEN; __DSB(); GPIOA -> MODER |= GPIO_MODER_MODER5_0; //as output GPIOA -> ODR |= GPIO_ODR_ODR_5; //set high GPIOA -> ODR &=~ GPIO_ODR_ODR_5; while(1){} } When I'm using ''GPIOA -> ODR ^=GPIO_ODR_ODR_5;'' led is still on. Best regards, ?ukasz #cmsis #stm32f42016-04-10 12:34 PM
Everything is ok.
LED active on '1'??2016-04-11 01:35 AM
Yes, LED is active on '1' but not turn off when I'm using
''GPIOA -> ODR &=~ (GPIO_ODR_ODR_5);'' or ''GPIOA -> BSRR = GPIO_BSRR_BR_5;''. Is it problem with code or with Nucleo?2016-04-11 02:08 AM
Did you try debug? Maybe you get hardfault?
2016-04-11 08:33 AM
Hi mendyk.lukasz,
This is a working code (tested on STM32F411RE Nucelo C-03). Try to test it in a template project of Hal library to figure out what it is causing problem in your project. Step by step debugging is your freind. The template project path is : stm32cubef4_1.11\STM32Cube_FW_F4_V1.11.0\Projects\STM32F411RE-Nucleo\Templates -Hannibal-2016-04-11 01:20 PM
Hi Hannibal,
I was using HAL library and it was working. I've already started with CMSIS. I was debugging it in Keil but LED didn't wanna turn off. I don't know what the problem is.2016-04-11 01:44 PM
Use the peripheral view within Keil to confirm that the configuration is correct, and that as you toggle the output pin you can see that reflected in the register and the pin. Use the debugger and step through the code. You can contrast the peripheral settings between the cases you have working, against those that don't.
Where the configuration uses multiple bits, you might want to mask it into the register, rather than assume initial conditions.2016-04-11 02:37 PM
Hi,
I don't know why but at this moment it's working. Thanks for all answers. I should spend more time at debugging and check config.