SCC131: weeks 7-12 Flashcards

(69 cards)

1
Q

what does the DAPlink firmware of the microbit allow?

A

-creates a “bridge” between PC and SWD
-means microbit can be seen as a USB disk on source computer
-allows hex files to be dropped into microbit folder and run on microbit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is bootloader mode on a microbit?

A

-hex files dropped into microbit folder will be written into interface MCU flash, not target MCU flash
-updates version of DAPlink
-name of USB becomes MAINTENANCE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is the microbit function for displaying text scrolled?

A

uBit.display.scroll(“Hello”);
uBit.display.scroll(“Hello”,100);
uBit.display.scroll(26);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is the microbit function for printing text?

A

uBit.display.print(“Hello”);
uBit.display.print(“Hello”,100);
uBit.display.print(26);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what are the options for display mode on a microbit?

A

-DISPLAY_MODE_BLACK_AND_WHITE
-DISPLAY_MODE_GREYSCALE
-DISPLAY_MODE_BLACK_AND_WHITE_LIGHT_SENSE
—display driver will sense the ambient brightness from the LEDs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is the microbit function for changing the displau mode?

A

uBit.display.setDisplayMode(display_mode_name);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is the function for setting the values of indiviual pixels on a microbit?

A

uBit.display.image.setPixelValue(x,y,255);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is the function on a microbit for getting the pixel value?

A

uBit.display.image.getPixelValue(x,y);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what is the layout of the x and y coordinates on a microbit?

A

x—->0 1 2 3 4
0
1
2
3
4

y

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

how would you create an image to be displayed on a microbit?

A

MicroBitImage myImage(“x,x,x,x,x\n x,x,x,x,x\n x,x,x,x,x\n x,x,x,x,x\n x,x,x,x,x\n”);
-where x is a colour value 0-255
uBit.display.print(myImage);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

list as many of the MicroBit classes encapsulated in MicroBit objects as possible (don’t NEED to know)

A

-uBit.i2c
-uBit.storage
-uBit.serial
-uBit.MessageBus
-uBit.buttonA
-uBit.buttonB
-uBit.buttonAB
-uBit.display
-uBit.accelerometer
-uBit.compass
-uBit.thermometer
-uBit.io
-uBit.radio

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what do the MicroBitButton classes have that makes them functional?

A

-action listeners
-detect when buttons on the microbit are pressed
-method isPressed() returns 1 if button has been pressed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

what is the key difference between a synchronous vs asynchronous implementation of microbit button activity?

A

-the synchronous uses a while loop and selection statements to constantly validate the buttons’ isPressed() functions to recognise when one has been pressed and perform the action
-the asynchronous implements an actionlistener for the button to raise an event only when a change is detected instead of constantly checking for change.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

how would an asynchronous button action listener be implemented?

A

uBit.messageBus.listen(MICROBIT_ID_BUTTON_AB, MICROBIT_BUTTON_EVT_CLICK, onButtonAB);

void onButtonAB(MicroBitEvent e){
——> button action performed e.g print value
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what are the three key parameters when using uBit.messageBus.listen() ?

A

-ID of component
-Event of interest, e.g button clicked
-Event handler to be called

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

what temperature does the microbit thermometer record?

A

-surface temperature of the application MCU
readTemp = uBit.thermometer.getTemperature();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

how would room temperature be taken from a microbit?

A

-would need to measure the offset between what it records and the actual temperature, then subtract the offset in the code
-uBit.thermometer.setCalibration(readTemp- (offset));
-readTemp = uBit.thermometer.getTemperature();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

what needs to be added to the code in order to utilise the MicrobitLog class?

A

include “MicroBitLog.h”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

what is the function of the microbit log class?

A

-used to store things in a table-like format

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

what are some of the main functions associated with microbit log class?

A

-beginRow(): opens files, creates new rows
-logData(“column name”,value)
-endRow(): close file, complete logging
-isFull(): checks if log is full
-setVisibility(): log needs to be made visible first
-setTimeStamp(): to initiate the logger

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What would be the difference between a sequentially and a asynchronously implemented thermometer sensor?

A

-sequential would continuously check the temperature within a while loop to identify any changes
-asynchronous implements an action listener that changes the temperature display only when a temperature change is sensed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

How should a temperature action listener be implemented?

A

uBit.messageBus.listen(MICROBIT_ID_THERMOMETER,MICROBIT_THERMOMETER_EVT_UPDATE, event handler name);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

how can the sampling period of a microbit thermometer be changed?

A

uBit.thermometer.setPeriod(time in ms);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

what does the preprocessor do?

A

-macro expansion
-#include directives, essentially copies the code into your file
-#define statements, defines global constants

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
what is the predominant function of the compiler?
-turns C into assembly code ----dependent on machine architecture
26
what is the predominant function of the assembler?
-translate assembly code into machine code -stores output in object file
27
what is the function of the linker?
-combines several object files together -makes sure any references to other files within code are resolved -two times: compiler-time linking, load-time linking (when program loaded into memory to be run)
28
what are some key sections of object files?
-machine code (text) -data (global constants) -required space for un-initialised data -symbol tables (information about every identifier/symbol/constant/procedure/function stored in a table) -relocation information (what function to look for in other code- linker)
29
when would you use gcc -c filename.c instead of gcc -o file filename.c?
-excludes linker from compiling process
30
what command runs only the linker?
ld *list of files or filepaths of files to be linked*
31
what command can be used to only run assembler?
gcc -S filename.c -means compile but don't assemble
32
what command can be used to see how gcc calls its subproblem?
-by using '-v' gcc -o file filename.c -v
33
what command can be run to only run the preprocessor?
gcc -E filename.c
34
how does linking object files work?
-uses the relocation records to fill in memory addresses where processes of another file are referenced in code -combines information from symbol tables and relocation records
35
what is the benefit of a symbol table?
allows for fast access to memory addresses of specific variables/processes
36
what are the two ways libraries can be linked?
-statically linked (archives) -dynamically linked (shared objects)
37
describe the concept of static linking
-program and library are linked at compilation time -program needs to be linked again for changes in library to be recognised -linked libraries typically have extension .a for archive
38
what are some advantages and disadvantages of static linking?
-when compiled it is clear which library is used -when programs copied, everything is there that is needed -programs need more disk space :(
39
describe the concept of dynamic linking
-libraries and programs are not combined by linker -linker inserts location of shared objects into the executable for the loader to see -referenced during run time, not compilation -shared objects have the extension .so
40
what are some advantages and disadvantages of dynamic linking?
-small file size -file does not need to be recompiled every time library is updated -impact of changing libraries not clear
41
what is the function of the loader?
-loading code and data into main memory -validating memory access
42
What is the process of the loader?
-allocate memory -copy address space from secondary to main storage -copy program onto stack -initialise registers -jump to start/ main()
43
what does a T symbol identify in code?
-symbol/function found in code
44
what does a symbol U identify in code?
-symbol undefined in program -needs to be found in another object file
45
describe the process of initial processing for a compiling file
-input file read into memory -continued lines combined into single lines -comments replaced with a space
46
how would the line userName = "schmin" be tokenised?
userName = identifier '=' = operator "schmin" = literal
47
what is the purpose of c pre-processor
-transforms program before processing
48
why is the c pre-processor often called the macro processor?
-allows the definition of macros -----brief abbreviations for longer constructs
49
what is tokenisation?
-input c fil is split into preprocessing tokens: -identifiers -numbers -string literals/literals -operators
50
what are the capabilities of the pre-processor?
-macro expansion -diagnostics (detecting errors at compilation) -conditional compilation (including/excluding segments from compilation) -including header files -influencing how code is compiled
51
why would conditional compilation be useful?
-code may differ based on machine or operating system -to compile source into multiple different object files
52
how can conditional compilation be done with selection statements?
- #if defined(VARIABLE) (can be written #ifdef VAR or #ifndef VAR) ----#endif - #elif VARIABLE2 >32 -#else *execute*
53
what are two potential methods of debugging?
-removing code until it functions -building up code until it functions -using print statements to validate data
54
How do microbits handle communication between devices?
-transmit 32 byte datagrams at once -can be: --an array of bytes --a sequence of characters --a packet buffer
55
what should be set up BEFORE transmitting or receiving data through a microbit?
-uBit.radio.enable(): enable radio module -uBit.messageBus.listen(MICROBIT_ID_RADIO, MICROBIT_RADIO_EVT_DATAGRAM, *event handler*): set up listener -set up event handler for receiving data -uBit.radio.setGroup(): determine which microbit group is being sent to
56
What is the code for transmitting datagrams?
uBit.radio.datagram.send(*datagram*)
57
what is the operating system kernel memory needed for?
-reserved by OS to control mapping between physical and virtual addresses
58
what is stack virtual memory needed for?
-function calls -arguments/local variables
59
what is a stack frame?
set of values pushed for one function call
60
what is the HEAP needed for?
-dynamic memory -for variables whose size if determined at run time -as they cant be statically determined by compiler before running
61
what is Block Starting Symbol (BSS) memory reserved for?
-global variables that are either un-initialised or equal to 0
62
what is the DATA portion of virtual memory reserved for?
-global static variables that have been initialised
63
what is the TEXT portion of virtual memory reserved for?
-Binary form of user code
64
What does the stack pointer reference?
-lowest address of stack in current frame
65
What is the frame/base pointer?
-references address of the previous frame
66
what is the saved instruction pointer?
reference to return address
67
What are some of the features of the memory layout of a microbit?
-memory is shared by micro-controller/on-board peripherals/external peripherals
68
what allows microcontroller to interact with other GPIOs (peripherals/external devices)?
memory-mapped IO
69