Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize I2C communication.
Embedded C
I2C_Init([1]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using UART baud rates instead of I2C clock speed.
✗ Incorrect
The standard I2C clock speed is 100kHz, so 100000 is used to initialize I2C.
2fill in blank
mediumComplete the code to send data over I2C.
Embedded C
I2C_Start();
I2C_Write([1]);
I2C_Stop(); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using baud rates or clock speeds instead of device address.
✗ Incorrect
0x50 is a common 7-bit I2C device address used to send data.
3fill in blank
hardFix the error in the I2C read function call.
Embedded C
uint8_t data = I2C_Read([1]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 which stops reading prematurely.
✗ Incorrect
Passing 1 means sending an ACK after reading to continue reading more bytes.
4fill in blank
hardFill both blanks to create a dictionary of device addresses and their names.
Embedded C
const char* devices = {
[1]: "Sensor",
[2]: "EEPROM"
}; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid or uncommon addresses.
✗ Incorrect
0x40 and 0x50 are common I2C addresses for sensors and EEPROM devices respectively.
5fill in blank
hardFill all three blanks to complete the I2C communication sequence.
Embedded C
I2C_Start(); I2C_Write([1]); uint8_t data = I2C_Read([2]); I2C_Stop(); return [3];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Returning 0 instead of the read data.
Using wrong device address.
✗ Incorrect
Start communication with device 0x68, read data with ACK (1), then return the data read.