Question
Why the led 'PA1' turns on after switching 'on' a register "*GPIOA_MODER" and turns 'off' after the switching 'on' a register "*GPIOA_ODR"?
I'm studying a registers...
I have stm32407vg and the LED is on the 'PA1' and I need that the LED turned 'On' after command witch It should turn it 'ON'. In may case after line № 18.
But 'LED' turns 'ON' after line №16 and turns 'OFF' after line № 18
Could you tell me why it happens?
Below my code.
#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)
{
uint32_t *RCC_AHB1ENR = (uint32_t*)0x40023830; // Base address + Adress ofset=0x30 from table "RCC AHB1 peripheral clock register (RCC_AHB1ENR)"
uint32_t *GPIOA_MODER = (uint32_t*)0x40020000;// Base address + Adress ofset=0x00 from table "GPIO port mode register (GPIOx_MODER) (x = A..I/J/K)"
uint32_t *GPIOA_ODR = (uint32_t*)0x40020014;// Base address + Adress ofset=0x14 from table "GPIO port output data register (GPIOx_ODR) (x = A..I/J/K)"
// 1. Enable the clock for GPIOA peripheral in the AHB1ENR
*RCC_AHB1ENR |= 1<<0;
// 2. Configure the mode of the IO pin a output
*GPIOA_MODER |= 0<<3 | 1<<2;
// 3. SET 1th bit of the uotput data register to make I/O pin-1 a HIGH
*GPIOA_ODR |= 1<<1;
/* Loop forever */
while(1){
// for(uint32_t i=0; i < 300000; i++ );
// *GPIOA_ODR |= 1<<0;
// for(uint32_t i=0; i < 300000; i++ );
//*GPIOA_ODR &= ~(1<<0);
}
}