/*#define DELAY 1000000
void setup() {
volatile unsigned int *RCCA_clk_en=(volatile unsigned int*) 0x40023830;
volatile unsigned int *GPIOA_dir=(volatile unsigned int*) 0x40020000;
volatile unsigned int *GPIOA_out=(volatile unsigned int*) 0x40020014;
*RCCA_clk_en |=(1<<0); // Enable clock access to GPIOA
*GPIOA_dir |= (1<<10); // 19: Set bit 10 to 1
*GPIOA_dir &= ~(1<<11); // 20: Set bit 11 to 0
long int a;
while(1)
{
// 22: Set PA5(LED_PIN) high
*GPIOA_out |= (1<<5);
for(a=0;a<DELAY;a++);
*GPIOA_out &= ~(1<<5);
for(a=0;a<DELAY;a++);
}
}
void loop() {
}*/
#define DELAY 1000000
void setup() {
Serial.begin(115200);
volatile unsigned int *RCC_AHB1ENR = (volatile unsigned int*) 0x40021014;
volatile unsigned int *GPIOA_MODER = (volatile unsigned int*) 0x48000000;
volatile unsigned int *GPIOA_ODR = (volatile unsigned int*) 0x48000014;
*RCC_AHB1ENR |= (1 << 0); // Enable clock for GPIOA
// Set PA5 as output
*GPIOA_MODER &= ~(3 << (2 * 5)); // Clear mode bits for PA5
*GPIOA_MODER |= (1 << (2 * 5)); // Set PA5 to output mode
long int a;
while(1)
{
*GPIOA_ODR |= (1 << 5); // Set PA5 high
for (a = 0; a < DELAY; a++);
*GPIOA_ODR &= ~(1 << 5); // Set PA5 low
for (a = 0; a < DELAY; a++);
}
}
void loop() {
// Not used
}
Loading
st-nucleo-c031c6
st-nucleo-c031c6