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.

USB stack interfering with ADC sampling

I've got a situation where I'm running the ADC on a TM4C123GE6PMI at 500ksps and pushing the data into memory.  I have the USB set to an interrupt priority of 0x60 using the

IntPrioritySet();

call.  I've got the ADC set to 0x00 which is the highest priority.  I'm DMAing the data to memory so the CPU just checks a couple if's in main, moves the samples to buffers and services the USB stack.  The problem I'm having is that it works fine when it runs NOT plugged into USB.  When I run it while plugged into USB I get errors in my data.  It seems like the stack needs to be serviced so often or something and causes this problem.  If I use these calls

USBDevDisconnect(USB0_BASE);
USBDevConnect(USB0_BASE);

to disconnect it when I trigger and reconnect when my recording is done my data looks good.  Is there anything I can do other than disconnect/reconnect to get the stack to chill out?  I'm setup as a HID device. 

Thanks,

Rob

  • Even if the USB interrupt priority would be set less than ADC, the evoked procedures by the USB interrupt could disturb the ADC operation. For diagnosis, temporarily disable Suspend or SOF interrupt, while the ADC runs sampling.

    #include "driverlib/usb.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_usb.h"
    #include "inc/hw_types.h"

    HWREGB(USB0_BASE + USB_O_IE) &= ~USB_INTCTRL_SUSPEND;  // disable suspend interrupt
    HWREGB(USB0_BASE + USB_O_IE) |=  USB_INTCTRL_SUSPEND;  // enable suspend interrupt

    HWREGB(USB0_BASE + USB_O_IE) &= ~USB_INTCTRL_SOF;  // disable SOF interrupt
    HWREGB(USB0_BASE + USB_O_IE) |=  USB_INTCTRL_SOF;  // enable SOF interrupt

    Tsuneo

  • Hey Tsuneo,

    Thank you for the reply.  Also thanks for the code you posted.  That is very helpful as I'm not super knowledgeable about the USB stack.  I tested this out and disabling the USB fixed my sampling problem.  Since I couldn't come up with enough optimizations in my code I bumped the optimization level of the compiler from 1 to zero.  This actually worked out after a couple hours of work/tweaking etc...  It is now up and running100% as far as I can tell. 


    I did run into a rather nasty problem where a normal integer variable was being changed randomly in my main loop while spinning and servicing the USB link.  I tried going through the disassembly for a few hours and didn't have any luck getting to the bottom of this.  I re-wrote some of my code and long story short it came back and works fine, but the original way I was doing it was causing a settings variable to change value.  So my question would be, does TI have any app notes about debugging assembly and code problems that would cause you to get into the assembly?  I'd like to become better at debugging on this level.  It would be awesome if they had some app notes/examples of debugging some different problems just to help get me started.

    Thanks,

    Rob

  • I think you are looking for something like this :

    http://processors.wiki.ti.com/index.php/Watchpoints_for_Stellaris_in_CCS

    Actual debug/trace capabilities also depend on the toolchain (besides of MCU hardware like DWT/ITM). Quite often this is the part you pay real money for. I'm using another IDE, so I can't speak from own experience with CCS.