C Language Flashcards

1
Q

What are the main topics covered in Advanced C Programming?

A

Arrays, Structures, Pointers, Pointers to Structures.

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

What is a one-dimensional array in C?

A

A contiguous block of memory storing elements of the same type, e.g., int x[100];

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

What is a two-dimensional array in C?

A

An array of arrays; e.g., float mydata[8][25]; representing 200 float elements.

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

What is a structure in C?

A

A user-defined data type that groups variables of different types under one name.

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

How is a structure defined and used in C?

A

Using the struct keyword; memory is only allocated when variables are created.

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

How does typedef simplify structures in C?

A

It creates an alias for the structure type, making code cleaner.

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

What are the advantages of using pointers in C?

A

Efficient data handling, dynamic memory, direct memory access, and complex data structures.

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

What is the address (&) operator in C?

A

A unary operator that returns the memory address of its operand.

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

What is the indirection (*) operator in C?

A

A unary operator that accesses the value stored at the pointer’s address.

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

What does *p mean if p is a pointer?

A

It accesses the value pointed to by p.

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

Why use pointers to structures?

A

For efficient function calls, dynamic allocation, external access, and multiple return values.

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

How do you access structure members via pointers?

A

Use the ‘->’ operator; e.g., ptr->member is equivalent to (*ptr).member.

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

What does the output of the pointer-to-structure example show?

A

Structure members are accessed and modified via pointers using -> operator.

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

What is the STM32 chip used in EE2028?

A

STM32L475VG on the B-L475E-IOT01A1 board.

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

What does a generic computer system diagram include?

A

Processor, RAM, Flash, Bus, external interfaces (USB, HDMI), internal peripherals.

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

What is a multi-tiered bus architecture?

A

High-speed and low-speed peripherals connected via separate buses with bridges.

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

What are the types of peripherals on STM32?

A

Core peripherals, on-chip peripherals, external devices on board.

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

How does software interact with hardware on STM32?

A

By reading/writing peripheral registers like memory.

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

What are the three types of peripheral registers?

A

Status (read), Control (write), Data (read/write).

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

Where to find information on peripheral registers?

A

Reference manuals, datasheets on Canvas > Files > Labs.

21
Q

How do libraries abstract peripheral access in C?

A

Using functions that internally manipulate pointers to registers.

22
Q

What is the difference between MMIO and PMIO?

A

MMIO uses shared address space with memory; PMIO uses separate address spaces.

23
Q

What is the difference between parallel and serial protocols?

A

Parallel uses multiple wires; serial transmits data one bit at a time.

24
Q

What is bus skew in parallel protocols?

A

Signal timing differences due to wire length or properties.

25
How do synchronous protocols differ from asynchronous?
Synchronous uses shared clock; asynchronous recovers timing from data.
26
What is the difference between bus-based and point-to-point?
Bus-based shares wires among devices; point-to-point has dedicated connections.
27
What is master-slave vs peer-to-peer communication?
Master-slave allows only the master to initiate; peer-to-peer allows all devices to initiate.
28
What is the difference between simplex, half-duplex, and full-duplex?
Simplex: one-way; Half-duplex: two-way, alternate; Full-duplex: two-way, simultaneous.
29
What is in-band vs out-of-band addressing?
In-band sends address and data together; out-of-band uses a separate address bus.
30
How many I/O lines does STM32L475VG have?
100 I/O lines across ports A to I, each with up to 16 pins.
31
How are GPIOs connected on STM32?
Directly to AHB2 bus for fast I/O timing.
32
Where to find GPIO register details?
RM0351 Reference Manual, pages 75–77.
33
What are the control GPIO registers?
MODER, OTYPER, OSPEEDR, PUPDR, LCKR, AFRL, AFRH, ASCR.
34
What does GPIOx_MODER configure?
Pin mode: Input (00), Output (01), AF (10), Analog (11).
35
What does GPIOx_AFRL/H configure?
Alternate functions for each pin, 4-bit codes (AF0 to AF15).
36
What is GPIOx_PUPDR used for?
Select pull-up (01), pull-down (10), or no pull (00) resistors.
37
What does GPIOx_OTYPER configure?
Output type: 0 = push-pull, 1 = open-drain.
38
Why use open-drain configuration?
For voltage level interfacing and shared bus communication.
39
What is the benefit of open-drain for communication?
Allows bi-directional communication on a single wire.
40
What does GPIOx_IDR do?
Reads logic level from input pin; it is read-only.
41
What does GPIOx_ODR do?
Controls output level on output pins; it is read/write.
42
What are GPIOx_BRR and GPIOx_BSRR?
Registers to reset (BRR) or set/reset (BSRR) bits atomically.
43
Why prefer BSRR/BRR over writing to ODR?
Atomic operation avoids read-modify-write hazards.
44
Where are HAL GPIO functions declared?
In stm32l4xx_hal_gpio.h; definitions in .c file.
45
How to write pin output with HAL?
Use HAL_GPIO_WritePin(GPIOx, GPIO_PIN_y, GPIO_PIN_SET).
46
What is the Blink_by_HAL example?
An example project on Canvas showing GPIO blink using HAL.
47
What does a sensor output represent?
A raw value that must be converted using a function f(value).
48
How to concatenate sensor bytes?
Combine MSB and LSB: ((MSB << 8) + LSB).
49
How to compute magnitude from sensor value?
Use linear interpolation: y = y1 + (value - x1)(y2 - y1)/(x2 - x1).