- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I would like to enable Trigger On option in my application to read some data .Trigger input is connected to the PA0 of CY7c68013A for TriggerOn detection .Host application send the vendor command when trigger is enabled in the software and 68013a wait until trigger becomes on.I tried with InterruptInEndPt xferdata function to read the data from the 68013a when trigger is enabled ,Fx2 sends data to Host application only when trigger is detected on PA0 .So fx2 takes some delay depend upon the trigger enable .The xferdata function waits for some timeout if transfer not completes successfully which is unnecessary in my application. please tell me about any event handler or some thing like that to detect the USB command from the 68013a.
host code
if (SelectedDevice.ControlEndPt != null)
{
SelectedDevice.ControlEndPt.ReqCode = 0x20;
g = SelectedDevice.ControlEndPt.XferData(ref DATA, ref bytes2send);
}
if (SelectedDevice.InterruptInEndPt != null)
g = SelectedDevice.InterruptInEndPt.XferData(ref buffer, ref bytes2);
Regards,
Sandeep
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Sandeep,
- The presence of data in the FX2LP can only be known through the XferData() API call. If the call returns true, the data is present in the device and is read back and if the call returns false, either the data is not available or the API has timed out.
- Since you are sending vendor commands, you can use the control endpoint to check if the trigger is ON or not based on which you can request data on the Interrupt endpoint. Please look at the below code snippet and let me know if this is suitable for your implementation. Also, let me know if you are reading any data from the external interface into the FX2LP buffers (interrupt endpoint).
BOOL DR_VendorCmnd(void)
{
switch (SETUPDAT[1])
{
case 0x20:
{
if(PA0)
{
EP0BUF[0] = 0xAB; // Value indicating trigger is ON
EP0BCH = 0x00;
SYNCDELAY;
EP0BCL = 0x01; // Arm endpoint with # bytes to transfer
SYNCDELAY;
trigger = TRUE;
}
else
{
EP0BUF[0] = 0xCD; // Value indicating trigger is OFF
EP0BCH = 0x00;
SYNCDELAY;
EP0BCL = 0x01;
SYNCDELAY;
trigger = FALSE;
}
break;
}
}
}
Best regards,
Srinath S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Sandeep,
Please correct if my below understanding is wrong.
- Trigger signal is generated by an external interface on the PA0 pin.
- Upon reception of the trigger signal, the data has to be sent by FX2LP to the host.
- Host reads the data from the FX2LP over an interrupt endpoint.
Kindly, let me know the below details.
- How is the read implemented from the host application? Is the read command being implemented in a continuous loop?
- Are you using vendor command to send the data to the host or is it over the interrupt endpoint?
Best regards,
Srinath S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello srinath,
I am not using any continuous loop in the Host application .I thought there will be some event handler to read
the data from fx2. My Fx2 code was
BOOL DR_VendorCmnd(void)
{
switch (SETUPDAT[1])
{
case 0x20:
{
trigger=TRUE;
EP0BCH = 0;
EP0BCL = 0x02; // Arm endpoint with # bytes to transfer
break;
}
}
void TD_Poll(void)
{
int i
if(trigger)
{
while(!PA0); // wait until trigger ON
if( !(EP1INCS & bmEPBUSY) ) // Is the EP1INBUF available,
{
LED=1;
EP1INBUF[0]=2;
EP1INBUF[1]=2;
}
EP1INBC =0X02;
trigger=FALSE;
}
So I have to use use a continuous loop in the host program to read the data from Fx2.
Now I am planning to use the codes like these
while(1) // continuous loop
{
1 send vendor command to from Pc
2 if the trigger is On then send an ok ack(0x11) to PC using EP1 interrupt
and read data from fifo using BulkInEndPt and exit the loop
3 if the trigger is not on then send and Nack(0x02) to pc using EP1 interrupt
}
regards,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Sandeep,
- The presence of data in the FX2LP can only be known through the XferData() API call. If the call returns true, the data is present in the device and is read back and if the call returns false, either the data is not available or the API has timed out.
- Since you are sending vendor commands, you can use the control endpoint to check if the trigger is ON or not based on which you can request data on the Interrupt endpoint. Please look at the below code snippet and let me know if this is suitable for your implementation. Also, let me know if you are reading any data from the external interface into the FX2LP buffers (interrupt endpoint).
BOOL DR_VendorCmnd(void)
{
switch (SETUPDAT[1])
{
case 0x20:
{
if(PA0)
{
EP0BUF[0] = 0xAB; // Value indicating trigger is ON
EP0BCH = 0x00;
SYNCDELAY;
EP0BCL = 0x01; // Arm endpoint with # bytes to transfer
SYNCDELAY;
trigger = TRUE;
}
else
{
EP0BUF[0] = 0xCD; // Value indicating trigger is OFF
EP0BCH = 0x00;
SYNCDELAY;
EP0BCL = 0x01;
SYNCDELAY;
trigger = FALSE;
}
break;
}
}
}
Best regards,
Srinath S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Srinath
Thanks for reply.I will try this code. I am using 8051F060 microcontroller ,which detects trigger ON.The data from sensor is send by the Microcontroller to FX2 using EP2out and Ep6in endponts in GPIF method .So I am connecting trigger input to both the 8051f060 and PA0 of FX2.
Regards,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Sandeep,
To get an even clearer picture of your setup, can you please send me a simple block diagram indicating the data flow and the trigger signals?
Best regards,
Srinath S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Srinath ,
I connected an port pin from the microcontroller to the FX2 PA0
,Microcontroller checks the External trigger and takes reading after that
change Port pin to high which is checked in the FX2 . It's working now
.Thanks for your help.
Best regards
Sandeep N C