0
0
Embedded Cprogramming~10 mins

I2C bus architecture (SDA, SCL) in Embedded C - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define the I2C data line (SDA) pin.

Embedded C
const int SDA_PIN = [1];
Drag options to blanks, or click blank then click option'
A5
B21
C13
D19
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing the SCL pin number instead of SDA.
2fill in blank
medium

Complete the code to define the I2C clock line (SCL) pin.

Embedded C
const int SCL_PIN = [1];
Drag options to blanks, or click blank then click option'
A21
B18
C5
D22
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing SDA and SCL pin numbers.
3fill in blank
hard

Fix the error in the I2C initialization function to set SDA and SCL pins correctly.

Embedded C
void i2c_init() {
    i2c_config_t conf;
    conf.sda_io_num = [1];
    conf.scl_io_num = 22;
    // other config code
}
Drag options to blanks, or click blank then click option'
A21
B5
C18
D19
Attempts:
3 left
💡 Hint
Common Mistakes
Setting SDA pin to the SCL pin number by mistake.
4fill in blank
hard

Fill both blanks to complete the I2C configuration struct with correct SDA and SCL pins.

Embedded C
i2c_config_t conf = {
    .sda_io_num = [1],
    .scl_io_num = [2],
    .mode = I2C_MODE_MASTER
};
Drag options to blanks, or click blank then click option'
A21
B22
C18
D19
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping SDA and SCL pin numbers.
5fill in blank
hard

Fill all three blanks to complete the I2C master initialization with correct pins and clock speed.

Embedded C
i2c_config_t conf = {
    .sda_io_num = [1],
    .scl_io_num = [2],
    .master.clk_speed = [3]
};
Drag options to blanks, or click blank then click option'
A21
B22
C100000
D400000
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong pins or incorrect clock speed values.