LPC55S28-EVK b2b I2C communication

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPC55S28-EVK b2b I2C communication

ソリューションへジャンプ
2,007件の閲覧回数
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

タグ(1)
0 件の賞賛
返信
1 解決策
1,985件の閲覧回数
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 件の賞賛
返信
1 返信
1,986件の閲覧回数
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 件の賞賛
返信
%3CLINGO-SUB%20id%3D%22lingo-sub-1889289%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ELPC55S28-EVK%20b2b%20I2C%E9%80%9A%E4%BF%A1%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1889289%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E7%9A%86%E6%A7%98%E3%80%81%3C%2FP%3E%3CP%3E%E3%83%9E%E3%82%B9%E3%82%BF%E3%83%BC%E3%81%8B%E3%82%89%E3%81%AEI2C%E3%83%87%E3%83%BC%E3%82%BF%E3%82%92%E5%8F%97%E4%BF%A1%E3%81%99%E3%82%8B%E3%81%9F%E3%82%81%E3%81%AE%E3%82%B9%E3%83%AC%E3%83%BC%E3%83%96%E3%81%A8%E3%81%97%E3%81%A6%E6%A7%8B%E6%88%90%E3%81%95%E3%82%8C%E3%81%9FLPC55S28-EVK%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%A6%E3%81%84%E3%81%BE%E3%81%99%E3%80%82%3C%2FP%3E%3CP%3E%E7%A7%81%E3%81%AFSDK%E3%81%AE%E4%BE%8B%E3%81%AEi2c_interrupt_b2b_transfer_slave%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%A6%E3%81%84%E3%81%BE%E3%81%99%E3%80%82%3C%2FP%3E%3CP%3E%E3%81%9D%E3%82%8C%E3%81%AF%E5%8B%95%E4%BD%9C%E3%81%97%E3%81%BE%E3%81%99%E3%81%8C%E3%80%81%E5%8F%97%E4%BF%A1%E3%81%97%E3%81%9F%E3%83%87%E3%83%BC%E3%82%BF%E3%81%8C%E6%9B%B8%E3%81%8D%E8%BE%BC%E3%81%BF%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%81%8B%E8%AA%AD%E3%81%BF%E5%8F%96%E3%82%8A%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%81%8B%E3%82%92%E6%A4%9C%E5%87%BA%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95%E3%81%8C%E3%82%8F%E3%81%8B%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93%E3%80%82%3C%2FP%3E%3CP%3E%E3%81%94%E5%AD%98%E7%9F%A5%E3%81%AE%E3%82%88%E3%81%86%E3%81%AB%E3%80%81I2C%E3%81%AE%E8%AA%AD%E3%81%BF%E5%8F%96%E3%82%8A%E3%81%BE%E3%81%9F%E3%81%AF%E6%9B%B8%E3%81%8D%E8%BE%BC%E3%81%BF%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%81%AF%E3%82%A2%E3%83%89%E3%83%AC%E3%82%B9%E3%81%AELSB%E3%81%AB%E4%BE%9D%E5%AD%98%E3%81%97%E3%81%BE%E3%81%99%E3%80%82%E3%81%9D%E3%82%8C%E3%82%92%E3%81%A9%E3%81%AE%E3%82%88%E3%81%86%E3%81%AB%E3%83%86%E3%83%86%E3%82%AF%E3%83%88%E3%81%97%E3%81%BE%E3%81%99%E3%81%8B%3F%3C%2FP%3E%3CP%3E%E3%81%94%E5%8D%94%E5%8A%9B%E3%81%84%E3%81%9F%E3%81%A0%E3%81%8D%E3%80%81%E8%AA%A0%E3%81%AB%E3%81%82%E3%82%8A%E3%81%8C%E3%81%A8%E3%81%86%E3%81%94%E3%81%96%E3%81%84%E3%81%BE%E3%81%97%E3%81%9F%3C%2FP%3E%3CP%3E%E3%82%88%E3%82%8D%E3%81%97%E3%81%8F%E3%81%8A%E9%A1%98%E3%81%84%E3%81%97%E3%81%BE%E3%81%99%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E