2013-01-14 12:53 AM
Hi, I am currently porting robotics software from STM32F1 (Cortex M3) to STM32F4 (Cortex M4). I want to write a simple program to switch on an LED via digital out. The program is supposed to send a digital input interrupt from a pushbutton and output to LED when it is pressed. Somehow I cannot get my digital input configuration to work. I get strange result, which is, I can only initialize GPIO pin for input from GPIO-E Pin 0. After this, initialization does not work. Even if I only used Pin 0 in my code, it does not work. So I commented off initialization for the rest of the pins and use polling technique for Pin 0 (if-else button is pushed, turn off LED). It still does not work. Any idea where to look?
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; GPIO_Init(GPIOE, &GPIO_InitStructure); // Initialize pin 0 //CODE DOES NOT WORK BELOW THIS POINT GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; GPIO_Init(GPIOE, &GPIO_InitStructure); // Initialize pin 1 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; GPIO_Init(GPIOE, &GPIO_InitStructure); // Initialize pin 2 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; GPIO_Init(GPIOE, &GPIO_InitStructure); // Initialize pin 3 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; GPIO_Init(GPIOE, &GPIO_InitStructure); // Initialize pin 4 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; GPIO_Init(GPIOE, &GPIO_InitStructure); // Initialize pin 5 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_Init(GPIOE, &GPIO_InitStructure); // Initialize pin 6 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; GPIO_Init(GPIOE, &GPIO_InitStructure); // Initialize pin 7 #gpio-digital-in2013-01-22 09:43 AM
Dear f.d.,
I have been experimenting with the GPIO using the stmf4discovery board, and the example firmware software. They have one called: IOToggle, or something close to that name in their example software. I started from their working software from the discovery kit example, and then kept modifying their code to do more and more of what I needed. When the code stopped working, I at least had gone from 'working' code to 'nonworking' code, and thus I could pinpoint what was not working.I did bump into a quirk, I was changing a bit that I had 'initialized' as an 'input', to later on be an 'analog' function bit, but it wouldn't work. so I had to only initialize the bit once, for now.One thing you could try is what another poster had suggested: notice how he initialized a number of bits, using the logical OR command, with symbol |. This also was used in the STMF4Discovery firmware examples, and worked good.Good luck!