This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How can I use GPIOA and GPIOB at the same time?

This is the program I'm trying to run. It's actually a program for a running light but for GPIOB's LED which is connected for the first LED just stayed on all the time, while the other 3 LED which is at GPIOA is is a running light sequence.

#include "stm32f4xx.h"
void delayMs(int n);

int main(){
RCC -> AHB1ENR |= 3;
GPIOA -> MODER &= ~0x0000FC00;
GPIOA -> MODER |= 0x00005400;
GPIOB -> MODER &= ~0x00003000;
GPIOB -> MODER |= 0x00001000;

while(1){
GPIOB->BSRR |= 0x004000A0;
delayMs(500);
GPIOA->BSRR |= 0x00800060;
delayMs(500);
GPIOA->BSRR |= 0x004000A0;
delayMs(500);
GPIOA->BSRR |= 0x002000C0;
delayMs(500);
}
}

void delayMs (int n){
int i;
for(; n>0; n--)
for(i=0; i<3000; i++);
}

Can someone help me?

0