i2c call back is not getting called

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

i2c call back is not getting called

452 Views
sushmasan
Contributor II

Hello Team,

I am working with a DAC module (MCP47FEB21A0) that is interfaced with an LPC55S69 over I²C.

I observed that I2C_MasterTransferBlocking() works correctly, but when I use I2C_MasterTransferNonBlocking(), the I²C callback is never invoked.

I2C_MasterTransferNonBlocking() is returning kStatus_Success.

For reference, I2C_MasterTransferCreateHandle() is called once during I²C initialization.

Could someone please explain why the I²C callback is not getting called when using I2C_MasterTransferNonBlocking()?

Regards,
Santhosh

 

0 Kudos
Reply
5 Replies

261 Views
sushmasan
Contributor II

Hi @Harry_Zhang ,

I even tried it,

uint8_t txData[3] = {0};

txData[0] = (uint8_t) (reg_addr << 3);

txData[1] = (uint8_t)(data >> 8); /* Data high byte */

txData[2] = (uint8_t)(data & 0xFFU); /* Data low byte */

 

masterXfer.data = txData;

masterXfer.dataSize = 3; /* 3 bytes total */

 

I have some data which is of 2 bytes, so after the adding reg addr it becomes 3 bytes.

Still I²C callback is not getting called when I use I2C_MasterTransferNonBlocking().

 

Regards,

San

 

0 Kudos
Reply

414 Views
Harry_Zhang
NXP Employee
NXP Employee

Hi @sushmasan 

I think you can refer to the  lpcxpresso55s69_lpc_i2c_interrupt_b2b_transfer_master_cm33_core0 SDK demo.

Harry_Zhang_0-1767855362914.png

BR

Harry

0 Kudos
Reply

393 Views
sushmasan
Contributor II

Hi @Harry_Zhang ,

Thanks for your response.

I have other sensor modules that are working with non-blocking calls.

I am using a BMP390 sensor, and the I²C communication works fine with non-blocking calls. For example, if one of the register addresses is 0x01, I assign the subaddress as shown below:

masterXfer.subaddress = (uint32_t)0x01;


However, for the DAC (MCP47FEB21A0) module, the subaddress is assigned differently:

uint8_t subAddress;
subAddress = (uint8_t)(reg_addr << 3); // Based on the MCP47FEB21A0 datasheet, the register address must be shifted left by 3
masterXfer.subaddress = (uint32_t)subAddress;

Is it going to make any difference?

Regards,
San

0 Kudos
Reply

300 Views
Harry_Zhang
NXP Employee
NXP Employee

Hi @sushmasan 

I think you can try to set subaddressSize = 0 and put the DAC’s command byte(s) and data bytes directly in masterXfer.data, then start a write transfer.

BR

Harry

0 Kudos
Reply

222 Views
sushmasan
Contributor II

Yesterday I replied to your message, but mistakenly I did a reply to the topic. I am not sure whether you have noticed it or not, that's why responding to your message again here.

 

Hi @Harry_Zhang ,

I even tried it,

uint8_t txData[3] = {0};

txData[0] = (uint8_t) (reg_addr << 3);

txData[1] = (uint8_t)(data >> 8); /* Data high byte */

txData[2] = (uint8_t)(data & 0xFFU); /* Data low byte */

 

masterXfer.data = txData;

masterXfer.dataSize = 3; /* 3 bytes total */

 

I have some data which is of 2 bytes, so after the adding reg addr it becomes 3 bytes.

Still I²C callback is not getting called when I use I2C_MasterTransferNonBlocking().

 

Regards,

San

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2289725%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Ei2c%20call%20back%20is%20not%20getting%20called%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2289725%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%20Team%2C%3C%2FP%3E%3CP%3EI%20am%20working%20with%20a%20DAC%20module%20(MCP47FEB21A0)%20that%20is%20interfaced%20with%20an%20LPC55S69%20over%20I%C2%B2C.%3C%2FP%3E%3CP%3EI%20observed%20that%20I2C_MasterTransferBlocking()%20works%20correctly%2C%20but%20when%20I%20use%20I2C_MasterTransferNonBlocking()%2C%20the%20I%C2%B2C%20callback%20is%20never%20invoked.%3C%2FP%3E%3CP%3EI2C_MasterTransferNonBlocking()%26nbsp%3Bis%20returning%20kStatus_Success.%3C%2FP%3E%3CP%3EFor%20reference%2C%20I2C_MasterTransferCreateHandle()%20is%20called%20once%20during%20I%C2%B2C%20initialization.%3C%2FP%3E%3CP%3ECould%20someone%20please%20explain%20why%20the%20I%C2%B2C%20callback%20is%20not%20getting%20called%20when%20using%20I2C_MasterTransferNonBlocking()%3F%3C%2FP%3E%3CP%3ERegards%2C%3CBR%20%2F%3ESanthosh%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2289917%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20i2c%20call%20back%20is%20not%20getting%20called%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2289917%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F221349%22%20target%3D%22_blank%22%3E%40sushmasan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20think%20you%20can%20refer%20to%20the%26nbsp%3B%20lpcxpresso55s69_lpc_i2c_interrupt_b2b_transfer_master_cm33_core0%20SDK%20demo.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Harry_Zhang_0-1767855362914.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Harry_Zhang_0-1767855362914.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Harry_Zhang_0-1767855362914.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Harry_Zhang_0-1767855362914.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Harry_Zhang_0-1767855362914.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Harry_Zhang_0-1767855362914.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F372099i81F6BE7811F21EFC%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Harry_Zhang_0-1767855362914.png%22%20alt%3D%22Harry_Zhang_0-1767855362914.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EBR%3C%2FP%3E%0A%3CP%3EHarry%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2290313%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20i2c%20call%20back%20is%20not%20getting%20called%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2290313%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F229957%22%20target%3D%22_blank%22%3E%40Harry_Zhang%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3EThanks%20for%20your%20response.%3C%2FP%3E%3CP%3EI%20have%20other%20sensor%20modules%20that%20are%20working%20with%20non-blocking%20calls.%3C%2FP%3E%3CP%3EI%20am%20using%20a%20BMP390%20sensor%2C%20and%20the%20I%C2%B2C%20communication%20works%20fine%20with%20non-blocking%20calls.%20For%20example%2C%20if%20one%20of%20the%20register%20addresses%20is%200x01%2C%20I%20assign%20the%20subaddress%20as%20shown%20below%3A%3C%2FP%3E%3CP%3EmasterXfer.subaddress%20%3D%20(uint32_t)0x01%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EHowever%2C%20for%20the%20DAC%20(MCP47FEB21A0)%20module%2C%20the%20subaddress%20is%20assigned%20differently%3A%3C%2FP%3E%3CP%3Euint8_t%20subAddress%3B%3CBR%20%2F%3EsubAddress%20%3D%20(uint8_t)(reg_addr%20%26lt%3B%26lt%3B%203)%3B%20%2F%2F%20Based%20on%20the%20MCP47FEB21A0%20datasheet%2C%20the%20register%20address%20must%20be%20shifted%20left%20by%203%3CBR%20%2F%3EmasterXfer.subaddress%20%3D%20(uint32_t)subAddress%3B%3CBR%20%2F%3E%3CBR%20%2F%3EIs%20it%20going%20to%20make%20any%20difference%3F%3C%2FP%3E%3CP%3ERegards%2C%3CBR%20%2F%3ESan%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2291427%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20i2c%20call%20back%20is%20not%20getting%20called%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2291427%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F221349%22%20target%3D%22_blank%22%3E%40sushmasan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20think%20you%20can%20try%20to%26nbsp%3Bset%20subaddressSize%20%3D%200%20and%20put%20the%20DAC%E2%80%99s%20command%20byte(s)%20and%20data%20bytes%20directly%20in%20masterXfer.data%2C%20then%20start%20a%20write%20transfer.%3C%2FP%3E%0A%3CP%3EBR%3C%2FP%3E%0A%3CP%3EHarry%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2291948%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20i2c%20call%20back%20is%20not%20getting%20called%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2291948%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F229957%22%20target%3D%22_blank%22%3E%40Harry_Zhang%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3EI%20even%20tried%20it%2C%3C%2FP%3E%3CP%3E%3CSPAN%3Euint8_t%20txData%5B3%5D%20%3D%20%7B0%7D%3B%3C%2FSPAN%3E%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CP%3E%3CSPAN%3EtxData%5B0%5D%20%3D%20(%3C%2FSPAN%3E%3CSPAN%3Euint8_t%3C%2FSPAN%3E%3CSPAN%3E)%20(reg_addr%20%26lt%3B%26lt%3B%203)%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EtxData%5B1%5D%20%3D%20(%3C%2FSPAN%3E%3CSPAN%3Euint8_t%3C%2FSPAN%3E%3CSPAN%3E)(data%20%26gt%3B%26gt%3B%208)%3B%20%3C%2FSPAN%3E%3CSPAN%3E%2F*%20Data%20high%20byte%20*%2F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EtxData%5B2%5D%20%3D%20(%3C%2FSPAN%3E%3CSPAN%3Euint8_t%3C%2FSPAN%3E%3CSPAN%3E)(data%20%26amp%3B%200xFFU)%3B%20%3C%2FSPAN%3E%3CSPAN%3E%2F*%20Data%20low%20byte%20*%2F%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CDIV%3E%3CDIV%3E%3CP%3E%3CSPAN%3EmasterXfer.%3C%2FSPAN%3E%3CSPAN%3Edata%3C%2FSPAN%3E%3CSPAN%3E%20%3D%20txData%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EmasterXfer.%3C%2FSPAN%3E%3CSPAN%3EdataSize%3C%2FSPAN%3E%3CSPAN%3E%20%3D%203%3B%20%3C%2FSPAN%3E%3CSPAN%3E%2F*%203%20bytes%20total%20*%2F%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CSPAN%3EI%20have%20some%20data%20which%20is%20of%202%20bytes%2C%20so%20after%20the%20adding%20reg%20addr%20it%20becomes%203%20bytes.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EStill%20I%C2%B2C%20callback%20is%20not%20getting%20called%20when%20I%20use%20I2C_MasterTransferNonBlocking().%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CSPAN%3ERegards%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3ESan%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2292690%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20i2c%20call%20back%20is%20not%20getting%20called%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2292690%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EYesterday%20I%20replied%20to%20your%20message%2C%20but%20mistakenly%20I%20did%20a%20reply%20to%20the%20topic.%20I%20am%20not%20sure%20whether%20you%20have%20noticed%20it%20or%20not%2C%20that's%20why%20responding%20to%20your%20message%20again%20here.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F229957%22%20target%3D%22_blank%22%3E%40Harry_Zhang%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3EI%20even%20tried%20it%2C%3C%2FP%3E%3CP%3E%3CSPAN%3Euint8_t%20txData%5B3%5D%20%3D%20%7B0%7D%3B%3C%2FSPAN%3E%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CP%3E%3CSPAN%3EtxData%5B0%5D%20%3D%20(%3C%2FSPAN%3E%3CSPAN%3Euint8_t%3C%2FSPAN%3E%3CSPAN%3E)%20(reg_addr%20%26lt%3B%26lt%3B%203)%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EtxData%5B1%5D%20%3D%20(%3C%2FSPAN%3E%3CSPAN%3Euint8_t%3C%2FSPAN%3E%3CSPAN%3E)(data%20%26gt%3B%26gt%3B%208)%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%2F*%20Data%20high%20byte%20*%2F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EtxData%5B2%5D%20%3D%20(%3C%2FSPAN%3E%3CSPAN%3Euint8_t%3C%2FSPAN%3E%3CSPAN%3E)(data%20%26amp%3B%200xFFU)%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%2F*%20Data%20low%20byte%20*%2F%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CDIV%3E%3CDIV%3E%3CP%3E%3CSPAN%3EmasterXfer.%3C%2FSPAN%3E%3CSPAN%3Edata%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3D%20txData%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EmasterXfer.%3C%2FSPAN%3E%3CSPAN%3EdataSize%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3D%203%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%2F*%203%20bytes%20total%20*%2F%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CSPAN%3EI%20have%20some%20data%20which%20is%20of%202%20bytes%2C%20so%20after%20the%20adding%20reg%20addr%20it%20becomes%203%20bytes.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EStill%20I%C2%B2C%20callback%20is%20not%20getting%20called%20when%20I%20use%20I2C_MasterTransferNonBlocking().%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CSPAN%3ERegards%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3ESan%3C%2FSPAN%3E%3C%2FP%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E