Problem with GPIO
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2011-07-02 7:15 AM
Posted on July 02, 2011 at 16:15
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?
This discussion is locked. Please start a new topic to ask your question.
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2011-07-02 10:29 AM
Posted on July 02, 2011 at 19:29 the keil give me a HardFault_Handler why?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2011-07-03 7:15 AM
Posted on July 03, 2011 at 16:15
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.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2011-09-18 9:46 AM
Posted on September 18, 2011 at 18:46
This is because you have not configured RCC. I had the same problem.
