2021-01-30 01:20 AM
I am a beginner in embedded coding, I am trying to turn on user LED's of nucleo-l4r5zi board but its not turning on. kindly lead me to the solution. (I am using keil)
Thanks.
Code:
#include "stm32l4xx.h" // Device header
int main(void)
{
RCC->AHB2ENR |=3; //enable gpio group a,b,c clock
GPIOB->MODER |=0x10004000;
GPIOA->MODER |=0x400;
GPIOC->MODER |=0x4000;
while(1)
{
GPIOA->ODR = 0x20; //0b 0000 0000 0010 0000 to make PA5 high
GPIOB->ODR = 0x4080; //0b 0100 0000 1000 0000 to make PB7 and PB14 high
GPIOC->ODR = 0x80; //0b 0100 0000 1000 0000 to make PC7 high
}
}
2021-01-30 08:31 AM
Looks OK, except
> RCC->AHB2ENR |=3; //enable gpio group a,b,c clock
which wouldn't enable GPIOC (you'd need to |= 7).
But at least LED on PB14 should be lit.
JW