Flashcards
Embedded systems part 2
Cards in this deck (13)
- 1List three benefits that the usage of functions can have on the code and/or program development.It makes the code easier to read.
It makes code reusable.
The code can be split into smaller tasks. - 2Describe the difference between the following three types of documentation: • Code documentation (code comments) • API documentation • Application documentationCode documentation is written as comments throughout the program code. It tells the reader what the code does and how it is used. It could, for example, describe the parameters and returns of a function.
API documentation just tells the reader what the code does. This is what we used for our libraries. The reader doesn’t have to read the code to understand what is in our library.
Application documentation is, for example, flowcharts and state diagrams. - 3What equation would you need to find the digital output from an ADC?n=(Vin/Vref) *((2^m)-1)
n= digital representation
m= bit width of ADC
Vin= analog input voltage
Vref= reference voltage/ voltage range - 4The AnalogIn class provides two different functions in order to read from the ADC (read, read u16) (a) Describe the difference of the two functions by describing their return values. (b) In what relationship do the two functions stand?
- 5A 1 MHz clock signal is connected to a 16 bit counter. After the counter has reached its maximum value, the counter starts counting from 0 again. How many times will the counter overflow in one minute?(60s*1000ticks/s)/(2*16)=915 times
- 6What is an ISR?ISR stands for Interrupt Service Routine. When a certain input is communicated to the program the ISR will trigger a function that performs a task in response to that input.
- 7When using libraries, an embedded system program typically consists of multiple source and header files. Describe the main role of the linker in this case.Every source and header file is compiled into separate object files. The linker's job is to connect the object files and combine them into one .bin file.
- 8An include guard (see below) is implemented with precompiler statements. # ifndef TEST # define TEST # endif (a) Where are include guards typically implemented? (b) Explain what an include guard “guards” against and describe how it works.a) Include guards are typically used at the top of a header file.
b) An include guard prevents a file from being included more than once. If TEST is already included, the #ifndef statement will return a false value and TEST will not be included again. - 9A PWM output can, for example, control the intensity of an LED. However, microcontrollers typically do not have many PWM channels. Describe how you could create a similar functionality on any GPIO pin. Start by explaining how PWM works.PWM is used to simulate an analog output on a digital pin by quickly toggling the state of a GPIO pin. It turns it on and off at different periods to for example make an LED appear less bright.
- 10Consider the following line of code for the EFM32HG microcontroller. GPIO ->P [4]. DOUT |= (1 << 7) ; (a) What does this line of code do? Describe how it works. (b) Explain why the arrow operator is needed.a) It configures pin E7 as PushPull.
b) The arrow is a struct pointer that allows us to point out a specific register from a struct. - 11Consider you have a register with the name register. The register is 8 bit wide. Write a line of code that checks whether bit 5 in the register is set. Explain how the line of code functions.
- 12A 32768 Hz clock signal is connected to a timer module. The module uses a prescaler with a division factor of 8 and its counter is 16 bit wide. How long will it take for the timer to count from 0 to its maximum value?Max value: 65535
New frequency: 32768/8=4086 Hz
Time: 65535/4096=16s - 13For every interrupt source, an interrupt flag exists in some register. (a) What is the interrupt flag used for? (b) Explain what happens if the interrupt flag is not cleared in the callback function of the interrupt?
Information
- Description
- Embedded systems Flashcards on Embedded systems part 2, created by Emma Alamaa on 01/01/2020.
- Created by
- Emma Alamaa
- Views
- 1
- Rating