FX3 indicate USB activity with LED

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
DaAd_1176526
Level 1
Level 1

Hi,

we are using FX3 for bulk transfers. I have assigned GPIO45 to be connected to the LED and control its ON/OFF state from the code. This part works fine. Now I need to lit it only when we transfer data over USB. I tried to use input->buffer_p.count in DMA Callback function but it seems it's always set to buffer size. How can I find if we are actually sending or receiving data over USB?

0 Likes
1 Solution
KandlaguntaR_36
Moderator
Moderator
Moderator
25 solutions authored 10 solutions authored 5 solutions authored

Hello,

Note that the DMA Callback occurs in two cases:

1. The buffer is full

2. Short Packet or zero packets received

You might be sending a full buffer of data and looking for it in the DMA Callback.

Please let me know whether how many BULK Endpoints are used in your application.

If you set the DMA Channels in Manual mode, you can set the GPIO to high when there is a producer event in DMA callback.

Use a timer in which you need to turn off the LED, if there is no DMA callback after a TIME_PERIOD.

This timer needs to be reset when there is a producer event hence the LED keeps blinking.

This is not possible with AUTO DMA Channel.

You may use Events to turn on and turn off the LED in DMA callback and look for the event in the main thread.

Regards,

Sridhar

View solution in original post

0 Likes
4 Replies
KandlaguntaR_36
Moderator
Moderator
Moderator
25 solutions authored 10 solutions authored 5 solutions authored

Hello,

Note that the DMA Callback occurs in two cases:

1. The buffer is full

2. Short Packet or zero packets received

You might be sending a full buffer of data and looking for it in the DMA Callback.

Please let me know whether how many BULK Endpoints are used in your application.

If you set the DMA Channels in Manual mode, you can set the GPIO to high when there is a producer event in DMA callback.

Use a timer in which you need to turn off the LED, if there is no DMA callback after a TIME_PERIOD.

This timer needs to be reset when there is a producer event hence the LED keeps blinking.

This is not possible with AUTO DMA Channel.

You may use Events to turn on and turn off the LED in DMA callback and look for the event in the main thread.

Regards,

Sridhar

0 Likes

Hi Shidar,

thank you for prompt response. We have two bulk endpoints, one for IN direction and one for OUT direction.
Interface descriptor info is listed below.
Our firmware is based on slave fifo example code. I think I know how to control LED ON and OFF, I make it blink when we have open connection to our program but it blinks all the time.

Now I need only limit it to the moments when we actually send data over bulk endpoint. Your help is appreciated.

<INTERFACE 0>

<INTERFACE>

Interface="0"

InterfaceNumber="0"

AltSetting="0"

Class="FFh"

Subclass="00h"

Protocol="0"

Endpoints="2"

DescriptorType="4"

DescriptorLength="9"

<ENDPOINT>

Type="BULK"

Direction="OUT"

Address="01h"

Attributes="02h"

MaxPktSize="1024"

DescriptorType="5"

DescriptorLength="7"

Interval="0"

<SUPER SPEED ENDPOINT COMPANION>

Type="SUPERSPEED_USB_ENDPOINT_COMPANION"

MaxBurst="0"

Attributes="00h"

BytesPerInterval="00h"

</ENDPOINT>

<ENDPOINT>

Type="BULK"

Direction="IN"

Address="81h"

Attributes="02h"

MaxPktSize="1024"

DescriptorType="5"

DescriptorLength="7"

Interval="0"

<SUPER SPEED ENDPOINT COMPANION>

Type="SUPERSPEED_USB_ENDPOINT_COMPANION"

MaxBurst="0"

Attributes="00h"

BytesPerInterval="00h"

</ENDPOINT>

</INTERFACE>

<INTERFACE 0>

0 Likes

Hello,

I finally figured it out. I used counters in DMA callbacks to register new transfers and in main loop just set LED on or off depending if we registered new transfers from previous cycle or not
Thank you for your help.

0 Likes

Great.

Regards,

Sridhar

0 Likes