mavishak / cnss-embedded

1 stars 0 forks source link

Trying to get the button B1 to work with led LD2 (no interrupts) #3

Open NaomiCreate opened 3 years ago

NaomiCreate commented 3 years ago

QUESTIONS: (main.c) trying to get the user button and led to work: While Debugging these two lines I notices an interesting phenomenon:

/*Configure user button PC13*/
    GPIOC->CRH &= 0xFF0FFFFF; //reset CNF and MODE only for bit 13, leave all the rest as they are
    GPIOC->CRH |= 0x00800000; //enable input with pull-up/ pull-down reset IDR bit 13 (see reference manual 9.2.2)

As implied GPIOC->IDR bit 13 is indeed reset to 0.

/*Configure led PA5*/
GPIOA->CRL &= 0xFF0FFFFF; //reset CNF and MODE only for bit 5, leave all the rest as they are
GPIOA->CRL |= 0x00200000; //PA5 configured to General purpose output push-pull | Output mode, max speed 2 MHz

But after these two lines, it is set back to 1. Why does that happen?