2011-07-02 07:15 AM
Hello, I try turn on and turn off a led when i press the button user1 but can not to do that, So i don´t understand my mistake.
I m using Keil with stm32_init.c, i config GPIOA.PIN1 like floating input... the main code is: int main (void) { stm32_Init (); GPIOC->BSRR = (1 <<9); GPIOC->BSRR = (1 <<8); while(1) { if (!((GPIOA->IDR & 0x0001) == 0 )) // Check if S2 is not pressed { GPIOC->BSRR = (1 <<8); } else { if (((GPIOA->IDR & 0x0001) == 0 )) // Check if S2 is pressed { GPIOC->BSRR = (1 <<24); } } } // end while } // end main can help?2011-07-02 10:29 AM
2011-07-03 07:15 AM
Check that you are enabling the clocks and GPIO's correctly.
For the Hard Fault, check first you are targeting the right CPU in your project. Hard faults typically occur because you're touching the wrong memory. Try debugging be stepping through the code until the fault occurs, or get the hard fault handler instrumented to provide details of the core state, and where in your code it faulted. Try looking for the example provided by Joseph Yiu.2011-09-18 09:46 AM
This is because you have not configured RCC. I had the same problem.