Announcements
IMPORTANT: Cypress Developer Community currently doesn’t allow sign-in to prepare for the upcoming transition. To learn more, check out our announcement.
cancel
Showing results for 
Search instead for 
Did you mean: 

USB Low-Full-High Speed Peripherals

shvo_3974456
New Contributor

Hi All,

I am using USB CY7C65215  for my usb projector connection , here is my visual c++ sample code as well as attached cyusbserial.dll so please have a look it

BYTE *writeBuffer = new BYTE[1];

ZeroMemory(writeBuffer, (sizeof(BYTE) * 1));

writeBuffer[0] = (BYTE)83;

CY_RETURN_STATUS num1 = Write((BYTE)27, writeBuffer, len1);

*************** Write Function Code

CY_RETURN_STATUS Write(UCHAR byteSlaveAddres7bit, UCHAR *buf, UINT32 len)

{

CY_I2C_DATA_CONFIG* dataConfig = NULL;

CY_DATA_BUFFER* writeBuffer = NULL;

UCHAR *pszWriteBuffer = NULL;

try

{

dataConfig = new CY_I2C_DATA_CONFIG();

CHECK_NULL(dataConfig)

writeBuffer = new CY_DATA_BUFFER();

CHECK_NULL(writeBuffer)

pszWriteBuffer = new UCHAR[len];

CHECK_NULL(pszWriteBuffer)

memset(pszWriteBuffer, 0, len);

memcpy(pszWriteBuffer, buf, len);

dataConfig->slaveAddress = byteSlaveAddres7bit;

dataConfig->isStopBit = (BOOL)TRUE;

writeBuffer->length = (UINT32)len;

writeBuffer->buffer = pszWriteBuffer;

CY_RETURN_STATUS cyReturnStatus = LTWrite(mHandle, dataConfig, writeBuffer, 5000U);

SAFE_DELETE(pszWriteBuffer)

SAFE_DELETE(dataConfig)

SAFE_DELETE(writeBuffer)

return cyReturnStatus;

}

catch(std::exception &e)

{

SAFE_DELETE(pszWriteBuffer)

SAFE_DELETE(dataConfig)

SAFE_DELETE(writeBuffer)

throw LTException(e.what());

}

};

** CY_RETURN_STATUS cyReturnStatus = LTWrite(mHandle, dataConfig, writeBuffer, 5000U);

Above line always return CY_ERROR_I2C_DEVICE_BUSY and please find attached cyusbserial.dll which I am using for read/write operation.

When I have checked the same thing from Cypress SDK -> Cypress\USB-Serial SDK\examples\usbserialexample\i2cmaster then also I am getting the same error.

Thanks In Advance.

Shailesh Vora.

0 Likes
1 Solution
YangyangC_06
Employee

Yes, you're right. I make a research on google and have a basic knowledge of loadLibrary function. Thanks for your information.

The code looks like fine. Could you please try to capture the I2C waveform when you load DLL and call I2Cwrite using logic analyzer?

Logic Analyzers from Saleae - #1 with Professional Engineers

Could you please check if it's the hardware issue? Is the I2C device ready to receive data?

Replace the I2C device with an EEPROM to test if the code(I2C write) could excute well.

It should be abnormal for you to always get I2C_deivce_busy error code.

View solution in original post

0 Likes
14 Replies
YangyangC_06
Employee

Hi Shailesh,

Can you try to run your code to see if it works on CYUSBS236/234 board? You mentioned that you have checked the demo code under SDK path and get same error. We need to check if it is a hardware issue.

0 Likes
shvo_3974456
New Contributor

Thanks for the reply.

You mean to change hardware chip ? , If yes then we already tried it.

Can't we do something like Re-Set that chip configuration via HX3 Blaster plus utility ? or any other way to reset ?

Because we already changed all the chip and checked but getting the same error.

0 Likes
YangyangC_06
Employee

Can you upload the whole project? I could check and debug it with CYUSBS236.

BTW, why do you mention HX3 blaster utility in this thread which discusses USB-serial chip?

0 Likes
shvo_3974456
New Contributor

I am sorry , we can't upload the project but apart from project what code I have posted in the blog is giving the error. rest of the code is same which has been mentioned in the sample cypress SDK Project.

I don't know about HX3 blaster utility , but from google I heard that might be we can re-set the micro chip setting so I asked , I don't know what's the purpose of that utility.

But how can we go in depth of that error ? we don't have any alternative ways to resolve it ?

0 Likes
YangyangC_06
Employee

You paste the code but it is hard to check and debug.

Please delete un-releated code and set up a simple project which could re-produce this issue.

I have mentioned that I met no prolbem using example code and CYUSBS236 board.

0 Likes
shvo_3974456
New Contributor

I am trying to send you the project but not able to found any attachment link so can you please share your email id

0 Likes
YangyangC_06
Employee

You could click "Use advanced editor" and then click "attach"

BaiduShurufa_2019-2-18_14-54-55.bmp

BaiduShurufa_2019-2-18_14-55-12.bmp

0 Likes
shvo_3974456
New Contributor

Thanks for the reply.

please find the attached sample project where I stuck in Write function

0 Likes
YangyangC_06
Employee

Do  you miss anything since I see many undefined data type and functions.

BaiduShurufa_2019-2-18_17-17-58.bmp

0 Likes
shvo_3974456
New Contributor

Hi,

That all is microsoft visual c++ library or header file and it's default  , given project developed in vs2017 and it's DLL project so to run it.

I just checked it and that type def available in

C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\shared\minwindef.h

you have to either use that compiled dll into any other project or you can directly check the logic from LTMachineConfig.cpp -> initProjector()

main flow begins from the initProjector() function.

0 Likes
YangyangC_06
Employee

Hi Shailesh,

I review your code to find you define LTWrite() and it will invoke GetProcAddress() in further, but there is no definition of this function.

Could you please call the API CyI2CWrite directly to write data on I2C bus?

0 Likes
shvo_3974456
New Contributor

Hi,

I think you may not aware about LoadLibrary Function of vc++ , It's simply call CyI2CWrite from cypress dll , nothing special in that code.

I am talking with my vendor technical team , let's see if they can help in this.

But what code I sent will be ok in visual c++ ? Because some time I was getting delay in projector Off.

Thanks & Regards

Shailesh

0 Likes
YangyangC_06
Employee

Yes, you're right. I make a research on google and have a basic knowledge of loadLibrary function. Thanks for your information.

The code looks like fine. Could you please try to capture the I2C waveform when you load DLL and call I2Cwrite using logic analyzer?

Logic Analyzers from Saleae - #1 with Professional Engineers

Could you please check if it's the hardware issue? Is the I2C device ready to receive data?

Replace the I2C device with an EEPROM to test if the code(I2C write) could excute well.

It should be abnormal for you to always get I2C_deivce_busy error code.

View solution in original post

0 Likes
YangyangC_06
Employee

Have you found the root cause?

0 Likes