This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

cppi41dma Host mode TX Dma complete waits locks up.

Other Parts Discussed in Thread: DSLR

 

Hello,

I have an issue with  "cppi41dma.c" code in starterware,  "dmaTxCompletion" function.

I am controlling  a DSLR camera and In order to keep up with changes in state, I must periodically poll the device to get status while connected.

If I just power off the camera or just pull the usb cable {which are possible operating scenarios} , my code locks up because it get stuck in the following line forever .

if(state == DMA_TX_COMPLETED)

       while ((HWREGH(usbInstance->usbBaseAddress + ulRegister) & 0x2) == 0x02);   

the 0x2 is TX complete in the hardware register, but this never happens since the device is no longer there , I found that an 0x4 is supposed to be set as error  after 3 failed attempts to send , but it never sets either.

I have not been able to detect anything in the code or registers to tell me the device unexpectedly disconnected and this line will only leave on succesfull transmisson which can never happen.

Is there any way to fix this or at least detect device disconnect and exit gracefully so i can shut off the pollling and be able to reconect when the device is turned back on?

 

 

  • Hello George,

    The DMA code is waiting for the Tx Transfer to end which never occurs as the device no longer exists. The right way to end this transfer would be to teardown the DMA tx channel after a certain time period and then check for the presence of the device. This portion of the code is currently missing from the USB stack and would unfortunately be available as a part of the next StarterWare release . But I am curious as I feel that you did not get a disconnect interrupt. Could you please try to exit the code after a small time period and check for a disconnect event. I would try to recreate this scenario and come back to you .