2020-04-19 03:23 PM
I just purchased the NUCLEO-STM32L47RG, and have tried using the following code below to press a switch to turn an LED on. However the code doesn't seem to actually be loading onto my microcontroller, I'm using Keil uVision 5 IDE if that makes a difference.
#include "stm32l4xx.h" // Device header
int main(void)
{
RCC -> AHB2ENR |= 0x04; // Enable Port C
RCC -> AHB2ENR |= 0x01; // Enable Port A
GPIOA -> MODER |= 0x400;
while(1)
{
if(GPIOC->IDR & 0x2000) // if PC13 is high
{
GPIOA->BSRR = 0x02; //Turn off LED
}
else
{
GPIOA->BSRR = 0x20; //Turn on LED
}
}
}
Any help on getting this working would greatly be appreciated.
2020-04-19 03:47 PM
> GPIOA -> MODER |= 0x400;
In the 'L4 family, default value of GPIOx_MODER is (except the debug pins) 0b11 = Analog.
JW