[stm32F411RE] Turning on LD2 through C, not working!
Hi ST Community!
Warning, this is about to be a long one :)
I have tried following the LED on step by step, but for my board. In this instance, the LED I am flashing is LD2 on my board which is connected to pin D13, based on the schematic below (which I obtained from https://www.st.com/en/evaluation-tools/nucleo-f411re.html#cad-resources)

I have used the AHB1 clock channel peripherals as dictated by the architecture in the datasheet of my boards chip.

System architecture up close

Full View
Now, onto its reference manual (RM0383) I use the following Addresses

Boundary addresses used for RCC and GPIOD

Based on this data, my clock enable register has been set as 0x4002 3800 + 0x30 ==> 4002 3830
To enable the peripheral for Port D the value 0x08 was written through an OR shift (see final code)

With this data, my register of initialising port D is 0x4002 0C00 + 0x0 ==> 0x40020C00. Pin 13 was highlighted
To clear the register for the 26th and 27th position the value 0xF3FFFFFF was calculated to AND shift, and then set up with calculated hex value of 0x04000000 with the OR shift (see final code)

The output register determined to be was 0x4002 0C00 + 0x14 ==> 0x4002 0C14
The final output value 0x2000 based on Pin 13 was masked on the output register with an OR operation (see final code)
The final code I used was this
#include <stdint.h>
#if !defined(__SOFT_FP__) && defined(__ARM_FP)
#warning "FPU is not initialized, but the project is compiling for an FPU. Please initialize the FPU before use."
#endif
int main(void)
{
/* Loop forever */
// Create the pointer variables for the addresses
uint32_t *pClkctrlreg = (uint32_t*)0x40023830; // It will store as a pointer not a number
uint32_t *pPortDModeReg = (uint32_t*)0x40020C00; // It will store as a pointer not a number
uint32_t *pPortDOutReg = (uint32_t*)0x40020C14; // It will store as a pointer not a number
// Enable the clock for the relevant register (AHB1)
// uint32_t temp = *pClkctrlreg; // read
// temp = temp | 0x08; //modify
// *pClkctrlreg = temp; //write
*pClkctrlreg |= 0x08;
// clear the 26th and 27th bit positions to reset it initially
*pPortDModeReg &= 0xF3FFFFFF;
// Set the 26th bit as general purpose output mode
*pPortDModeReg |= 0x04000000;
// Output register
*pPortDOutReg |= 0x2000;
while (1);
}
No lights! and I can confirm my LED wasnt busted, as I used an old default LED dimming code which works
I went to debug to monitor the registers to make sure it was working too, and bridged the CN5 to see if it helped but no avail!




