cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L476RG not using flashed design

kfg4
Associate

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.

1 REPLY 1

> GPIOA -> MODER |= 0x400;

In the 'L4 family, default value of GPIOx_MODER is (except the debug pins) 0b11 = Analog.

JW