CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

FYI: PIC24 family / PCD compiler / USB working

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Oli
Guest







FYI: PIC24 family / PCD compiler / USB working
PostPosted: Fri May 08, 2009 7:44 am     Reply with quote

Hi All

Have just got the CCS USB drivers working with the PIC24FJ256GB110 and PCD V4.092, but came across one problem.

After spending a few hours trying to figure out any hardware problems, I found none. The USB drivers looked fine, but I had run out of ideas so I started from the basics - The datasheet says:


Quote:

17.4.1 ENABLING DEVICE MODE
1. Reset the Ping-Pong Buffer Pointers by setting,
then clearing, the Ping-Pong Buffer Reset bit
PPBRST (U1CON<1>).
2. Disable all interrupts (U1IE and U1EIE = 00h).
3. Clear any existing interrupt flags by writing FFh
to U1IR and U1EIR.
4. Verify that VBUS is present (non OTG devices
only).
5. Enable the USB module by setting the USBEN
bit (U1CON<0>).
6. Set the OTGEN bit (U1OTGCON<2>) to enable
OTG operation.
7. Enable the endpoint zero buffer to receive the
first setup packet by setting the EPRXEN and
EPHSHK bits for Endpoint 0 (U1EP0<3,0> = 1).
8. Power up the USB module by setting the
USBPWR bit (U1PWRC<0>).
9. Enable the D+ pull-up resistor to signal an attach
by setting DPPULUP (U1OTGCON<7>).


Implementing this looks like:

Code:
#word U1CON = 0x0494
#bit PPBRST = U1CON.1

#word U1IE = 0x048C
#word U1EIE = 0x0490

#word U1IR = 0x048A
#word U1EIR = 0x048E

#bit USBEN = U1CON.0

#word U1OTGCON = 0x0486   
#bit OTGEN = U1OTGCON.2

#word U1EP0 = 0x04AA
#bit EPRXEN = U1EP0.3
#bit EPHSHK = U1EP0.0

#word U1PWRC = 0x0488
#bit USBPWR = U1PWRC.0

#bit DPPULUP = U1OTGCON.7


Code:
   //PPBRST = 1;     // not needed
   //delay_ms(10);   // not needed
   //PPBRST = 0;     // not needed

   //U1IE = 0;       // not needed
   //U1EIE = 0;      // not needed
   
   //U1IR = 0xFFFF;  // not needed
   //U1EIR = 0xFFFF; // not needed
   
   //verify Vbus is present
   
   //USBEN = 1;
   
   OTGEN = 1;        // needed
   
   //EPRXEN = 1;
   //EPHSHK = 1;     // not needed
   
   //USBPWR = 1;     // not needed
   
   DPPULUP = 1;      // needed



Basically, setting OTGEN and DPPULUP to 1 enables the CCS drivers to work as described (in my case). Hope this helps somebody.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group