One: Compile the first program
int main () // main function { } void SystemInit () // before execution of the main function will be invoked. Not be achieved. In the startup file is called { }
; Reset handler Reset_Handler PROC EXPORT Reset_Handler [WEAK] IMPORT __main IMPORT SystemInit LDR R0, =SystemInit BLX R0 LDR R0, =__main BX R0 ENDP
Two: LED light Schematic
Note: where is the green light PB0
Three: LED lighting - code for
(A) Step: green light LED lamp pins PB0, the port output data register must be set so that it outputs a low level corresponding to the pin, a voltage difference. Green lights
*(unsigned int*)(0x40010c0c) &= ~(1<<0);
(Ii) Step 2: Set the port requires low register, set the low eight 0-7, as general purpose push-pull mode, the maximum speed is set to 10MHZ
*(unsigned int*)(0x40010c00) |= (1<<0);
The difference is that the open-drain or push-pull:
open drain: an output terminal corresponding to the collector of the transistor, to obtain a high state requires a pullup resistor job. Adapted to make a current driving type, its ability to absorb a relatively strong current (typically less than 20ma).
Push-pull output: output may be high, low, connecting digital devices.
Open-drain circuitry refers to circuitry extremely MOS FET drain output. General usage will add an external pull-up resistor in the drain circuit. Complete open drain circuit should open-drain devices and the open drain pull-up resistors.
Generally refers to two push-pull transistors are controlled by two complementary signals, one transistor is always turned off when other
The introduction of a sentence: "multiplexed output current pin function peripheral control functions are not controlled by General IO, so you want to be driven by operating LED GPIO, then certainly with generic "
Speed could choose
(C) Step 3: Set the peripheral port when Zhongkai Qi GPIOB
*(unsigned int*)(0x40021018) |= (1<<3);
(D) all the code
int main() { *(unsigned int*)(0x40021018) |= (1<<3); *(unsigned int*)(0x40010c00) |= (1<<0); *(unsigned int*)(0x40010c0c) &= ~(1<<0); } void SystemInit() { }
(V) implement state