LPC55S28-EVK b2b I2C communication

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC55S28-EVK b2b I2C communication

Jump to solution
2,049 Views
Marconi_
Contributor I

Dear all,

I'm using LPC55S28-EVK configured as slave to receive I2C data coming from master.

I'm using SDK example i2c_interrupt_b2b_transfer_slave.

It works but I don't know how to detect if received data is write or read command.

As you know I2C read or write command depends on the LSB of address. How to tetect it ?

Thank you very much for your help and cooperation

regards

Tags (1)
0 Kudos
Reply
1 Solution
2,027 Views
Harry_Zhang
NXP Employee
NXP Employee

Hi @Marconi_ 

In I2C protocol, the LSB of the address byte is used to determine whether the command is a read or write operation. If the LSB is 0, it's a write operation; if it's 1, it's a read operation.

When you receive an interrupt indicating that data has been received, you can check the LSB of the address byte to determine whether it's a read or write operation.

Here's a simple example:

void I2C0_IRQHandler(void)
{

// Address match event occurred
uint8_t address = I2C0->ADDR;

// Check the LSB to determine read (1) or write (0)
if (address & 0x01)
{
// Read command (LSB is 1)
// Perform actions for read command
}
else
{
// Write command (LSB is 0)
// Perform actions for write command
}

}

Hope this will help you.

BR

Hang

 

View solution in original post

0 Kudos
Reply
1 Reply
2,028 Views
Harry_Zhang
NXP Employee
NXP Employee

Hi @Marconi_ 

In I2C protocol, the LSB of the address byte is used to determine whether the command is a read or write operation. If the LSB is 0, it's a write operation; if it's 1, it's a read operation.

When you receive an interrupt indicating that data has been received, you can check the LSB of the address byte to determine whether it's a read or write operation.

Here's a simple example:

void I2C0_IRQHandler(void)
{

// Address match event occurred
uint8_t address = I2C0->ADDR;

// Check the LSB to determine read (1) or write (0)
if (address & 0x01)
{
// Read command (LSB is 1)
// Perform actions for read command
}
else
{
// Write command (LSB is 0)
// Perform actions for write command
}

}

Hope this will help you.

BR

Hang

 

0 Kudos
Reply