- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to send you the project but not able to found any attachment link so can you please share your email id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You could click "Use advanced editor" and then click "attach"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you miss anything since I see many undefined data type and functions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have you found the root cause?