Here im using the stm32l discovery microcontroller. First i initialize the ports for the gpio ports for the leds and the user button.
I have it working now and the little program i have now makes the led blink. Every time you press the button the waiting time gets longer making the led blink longer. the problem now is that as soon as the waiting time exeeds 4 seconds or more its to hard for the microcontroller to notice the button press. Is there a way to make it that it always notices a button press
int main(void) {
char *RCCp = (char*) 0x40023800;
int *PAp = (int *) 0x40020000;
int *PBp = (int *) 0x40020400;
// RCC Config
*((int*) (RCCp + 28)) |= 0x3f;
*((int*) (RCCp + 32)) |= 1;
// Pin config
*PBp = 0x5000;
*PAp = 0x0000;
int speed = 100000;
int i = 0;
while (1) {
while (i++ < speed); // Waiting time
*(int*) (0x40020414) ^= 0xC0;
i = 0;
if ((*(int*) (0x40020010) & 0x0001) != 0x0) {
speed = speed * 2;
if (speed > 400000) {
speed = 100000;
}
}
}
return 0;
}