1/43
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What is the intended “flow” of code
#define variable definitions, main(), called functions below
How would you call an integer function turnLED within main, then what would the function definition look like if there was #define ON (1)
turnLED(ON), int turnLED(int state)
what are the different uint and int definition types for? What do we use typically?
unsigned and signed values. uint
What are GPIO MODER bit assignments 00 and 01?
Input and Output
What is the operator %?
gives remainder after division
When is XOR (^) = 1?
if only 1 is 1
how do you write an if statement with multiple alternatives. What does while(condition) do?
if (condition) … else if (condition)… else. While will repeat the while function as long as the condition is met
How do you mask (isolate certain bits) within a register by clearing the upper four bits of A then shifting 9 up to the 4 bits?
a = a & 0×0F, a = a | (9 << 4)
What does this do?: GPIOC->MODER &= ~(GPIO_MODER_MODE0 | GPIO_MODER_MODE1);
Clears the bits for PC0 and PC1
What does this do?: GPIOC->MODER |= (GPIO_MODER_MODE0_0 | GPIO_MODER_MODE1_0);
Sets bit 0 of each to 01 to declare output
What does this do?: GPIOC->OTYPER &= ~(GPIO_OTYPER_OT0 | GPIO_OTYPER_OT1);
Clears bits to zero for open drain output
What does this do? GPIOC->PUPDR &= ~(GPIO_PUPDR_PUPD0 | GPIO_PUPDR_PUPD1);
Clears bits for no pull up resistor
What does this do?: GPIOC->OSPEEDR |= ((3 << GPIO_OSPEEDR_OSPEED0_Pos) |
(3 << GPIO_OSPEEDR_OSPEED1_Pos));
Sets the speed for both pins to be 11 for the highest speed and shifts it left to the correct pin
What does this do?: GPIOC->BRR = GPIO_PIN_0 | GPIO_PIN_1;
Sets 1 to the bit reset register in both pins
What does this do?: RCC - > AHB2ENR |= ( RCC_AHB2ENR_GPIOAEN | RCC_AHB2ENR_GPIOCEN ) ;
Turns on the clock for both gpioa and gpioc
What are the two main paths of GPIO pins?
IDR and ODR
What is the problem with ODR? What can we use instead to mitigate this problem, and what is the word associated with the solution?
It takes too many clock cycles. Use BSRR on the GPIO pins to execute as a single operation, this is known as atomic
What is MODEx_Pos, MODEx_1, MODEx_0?
The bit position of mode x, 1 at bit 1 of mode x, 1 and bit 0 of mode x
How do you make a for loop for a variable Idx that starts at 0, has to be less than 5, and gets 1 added each iteration?
for (Idx = 0 ; Idx < 5 ; Idx++)
How do you define a variable PI to be 3.14? Where would this be?
#define PI (3.14). Header file
What is typedef used for and what is the syntax?
it is used to define a type of variable. typedef data_type name
How do you get a binary value from a number?
Divide by 2 and take remainder then reverse the output
How do you write pseudocode?
start with configurations, then how decisions are made
What is a switch statement? How do you create one?
A state defintion. switch(expression) { case constant-expression: statements; break: default: … }
what do .h files do?
They initialize variables and functions to be used within c files
In regards to functions, what does void mean? what does int mean?
void means nothing is returned by the function, int means an integer is returned
how do you use typedef to set up boolean logic?
typedef int bool;
#define false (0)
#define true (!false)
Where should you initialize most variables? Where do most functions belong in c code (not where they are called from)
initiate within the given function to avoid global variables. Belong below main()
What is debounce? How do we avoid it with software?
It is a strategy to avoid the oscillation that comes with switching. Checking once every few microseconds for state changes multiple times in a row
For timing diagrams, what are setup and hold times. What is minimum pulse width?
setup times are data time before clock edge, hold times are data time after clock edge. It is the time the clock must stay high or low long enough for the register to recognize it.
For LCD Control explain what the values mean, then what these are afterwards:
RS = 0 and 1, R/W = 0 and 1, E falling edge
command and data, write and read, LCD captures data. RS tells LCD what is being sent, R/W tells LCD what is being read/written, E tells LCD to capture the data on falling edge
What are flowcharts? How do you write them?
Flowcharts outline the reasoning behind code like pseudocode. You start with a oval and end with an oval, squares are processes, stop signs are decisions meant to branch
A 4 MHz clock is how many clock edges per second? One clock tick every how many seconds?
4M, 1/4M
What is the progression of the timer setup?
Clock, Prescaler, Counter, AAR/CCR, Interrupt
What do the Clock, Prescaler, Counter, AAR/CCR do?
the clock is the sources of edges to be counted, prescaler slows clock by dividing frequency, counter is 32 bits to count the clock edge amount, AAR sets the end of timer count, CCR can generate an event at a different point than AAR
What is upcount, downcount, center-alligned?
count from 0 to AAR then reset, count from AAR to 0 then reset, count from 0 to AAR then 0 repeatedly
What is continuous counting?
When you set AAR to the maximum value then let CCR set the intended period for events
How does an interrupt work? What are its parts?
It temporarily stops main() at an interrupt flag. When the timer generates an interrupt, the interrupt vector table allows reading of ISR addresses for each timer flag due to interrupt request
What are the bit options for OTYPER (OTx)?
0 = push-pull, 1 = open drain
What are the PUPDR 2 bit options?
00 - none, 01 - pullup, 10 - pulldown, 11 - reserved
For all types of initialization (PUPDR, MODER, OSPEEDR, etc) besides OTYPER, where are the 2 bits located? Where is the one bit for OTYPER?
the first bit is at 2 times the pin number, the bit is at the pin number
What is the BSRR options?
0-15 sets corresponding GPIO pin high, 16-31 resets GPIO pin low
What are the options for BRR?
0 - nothing, 1 - pin is set low
How do you make a negative number corresponding to its positive number (signed)?
write binary for number, flip every bit, add 1