You are on page 1of 6

Slides (5-8)

GPIO I/O
Input and output can be taken from or directed to data register or another peripheral
Output - push-pull, open drain + pull-up/pull-down
Input - floating, pull-up/pull-down, analog
Pull down register connected GND and pull up is to +5V

4 modes of GPIO mode register:


Input
Output
Alternate Function - connecting to peripheral device
Analog - ADC and DAC

GPIO speed register controls the slew rate or the rate at which a signal can change between
low/high values
Problems
All GPIO MODER Pins to 01 => 0x55555555
11 => 0xFFFFFFFF
ODR generally follows pin numbers from 1-16(a big maybe) and index numbers from 0-15
Referencing a memory address
The qualifier "volatile" informs the compiler that the value may have changed even
though no statements in the program updates it
3 useless methods -> direct, pointer, variable
Component analysis while performing a task at GPIOB
Solving a problem statement using incrementation
foo() function for incrementation (static int is used)
BX lr to exit from subroutine
Memory Alignment
"ALIGN" directive gives data alignment requirements to compilers. The syntax is "ALIGN
boundary, offset". The boundary is any power of 2. The default boundary is 4, making the
next variable align to a word boundary. The offset specifies how many bytes the next variable
should start from the word boundary. The default offset is 0.

Program Status Register


AIE
PSR = APSR + EPSR + IPSR

ADD vs ADDS (updates flags)

LSL vs LSLS

Values inside the register remains unchanged after shift operations


Difference between ROR and RRX
Reset value for MODER = 0x0010 0000
RCC_AHB1ENR for GPIOA => Clock register
Program to calculate factorial of a given number-Recursion

Program to find a maximum of an array


Two ways to return from a subroutine

Glowing LED at GPIO-G (not done)


Connected to Pin 13 and Pin 14
The numbering here is refer to both MODER and ODR

You might also like