PIC 24FJ USB MS Device problem

Discussion in 'Embedded Systems and Microcontrollers' started by Macilrae, Nov 30, 2013.

  1. Macilrae

    Thread Starter New Member

    Nov 30, 2013
    1
    0
    I have a working custom SD card datalogger using a Microchip 24FJ256GB106 and I am struggling, so far with no success, to add a USB port so I can read the card on my PC.

    I have unpacked Microchip's application using MPLAB & C30 and have it successfully compiled for my chip.

    I am working in Device mode and have a crystal oscillator - picture of my layout is attached.

    This is my configuration:

    _CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & FWDTEN_OFF & ICS_PGx3)

    _CONFIG2( PLL_96MHZ_ON & IESO_OFF & FCKSM_CSDCMD & OSCIOFNC_ON & POSCMOD_HS & FNOSC_PRIPLL & PLLDIV_DIV2 & IOL1WAY_ON)

    The software loads OK and I can place LEDs along the path for diagnostics -I have enabled USB_POLLING and my 'main.c' loops continuously through

    InitializeSystem();
    USBDeviceTasks();
    ProcessIO();

    but USBDeviceTasks() fails to reach CONFIGURED_STATE which causes ProcessIO() to abort.

    At present, the reason for not reaching CONFIGURED_STATE is because U1IRbits.TRNIF is not being set in usb_device.c

    I've tried three different generations of Microchip's library software and it must be able to work 'out-of-the-box' so I figure I am doing something dumb with my definitions maybe.

    Help much appreciated.
     
    • 24FJ.jpg
      24FJ.jpg
      File size:
      195.8 KB
      Views:
      29
  2. dsreinhard

    New Member

    Dec 5, 2013
    1
    0
    What frequency does your crystal oscillator run at?
     
  3. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    I've used the sample USB projects successfully in PIC18 and 32 projects, no issues along the way. Just built it and they will come.

    Did you do any mods to the code?
    Is the crystal correct? Did you check the speed?
    Did you swap +D and -D?
    Did you add (or remove) the bus pullup resistor?

    When I have a question about config settings (or any setting in general) I print out that page of the sheet and sit there with a pencil until I have a set I believe is correct, then proceed from there.

    Sample projects always build based on some pre-defined development boards by Microchip. You probably need to create your own custom hardware configuration so it runs on your board.
     
Loading...