Digital Electronics Term 2 Flashcards
Iterative and incremental processes in software development
Iterative: fixing errors in the next iteration of the code, testing then repeat
Incremental: features are added one at a time
Machine code, assembly language, high level definitions
MC: raw binary instructions, no abstraction
AL: symbolic notation for machine code instructions (ADD, SUB etc), slightly more human readable
HL: similar to natural language, lots of abstraction
Compiler, assembler definition
C: converts high level code into machine code
A: converts assemply language code into machine code
Portability in code definition and examples
Code being able to run on multiple different processors
Machine code = not portable. Would require rewriting for processors with different instruction sets
High level = very portable
Can use compilers for different processors means same code can be compiled multiple times
Compliation process: 4 steps
- Source code goes through Preprocessor. Involves being expanded with any files or macros
- Compilation: source code converted into assembly code made of of mnemonics of the instruction set architecture
- Assembly: assembly code is converted into binary machine code (object code) according to instruction format of the particular architecture
- Linking: combining object code together with any library code to create an executable file
Flags for c++ compliation stages (last one is special)
Other Flags for c++ compliation (two of them)
- E, -S, -c, g++
- Wall: outputs any warnings about the code
- O: optimises code, different levels (-O1, -O2, -O3)
Why is the main() function special compared to others?
It defaults to returned 0 (hence why its int main() )
Other functions must explicitly contain a return statement
What is the link between C and C++?
C++ is a superset of C
C code is also C++ code but not all C++ code is C code
What can’t variable names contain in C++?
Spaces, commas or special charactors other than underscore
Types of variable and their bit length: 6 in total. Think about sign and decimal places as well
Char (8 bits) Short (16 bits) Int (32 bits) Long long (64 bits) All can be unsigned or signed. Range example: char= 0-255 OR -128-127
Float (32 bits, 7 decimal places)
Double (64 bits, 16 decimal places)
Pull up/pull down resistors on input pins
PU: pin reads logic 1 by default, logic 0 from input
PD: pin reads logic 0 by default, logic 1 from input
Positive/negative logic on output pins
You can use a pin to sink/source small amounts of current Positive: Logic 1 on pin: 3.3 V Causes current to flow from the pin Pin acts as a current source Negative: Logic 0 on pin: 0V Causes current to flow from a supply into the pin Pin acts as a current sink
Mbed DigitalOut commands
write-set output to 1/0 (or use = as a shortcut)
wait-delay in code
BusOut-a way to address multiple pins at once (array with LSB first)
Example: array with 4 LED’s. Putting in 2 activates the second LED, 7 activates first 3 (think binary numbers)
Mbed DigitalIn commands
read-returns 0/1 depending on whether its 0V/3.3V on the input pin
mode-changes pin to pull up, pull down or pull none
PWN definition and uses
Pulse-width modulation
Outputs a periodic waveform controlled by changing its frequency and duty-cycle
Controls brightness of LEDs and speed of motors