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

USB with PIC24EP512GU810

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



Joined: 03 Apr 2014
Posts: 2
Location: Deutschland

View user's profile Send private message

USB with PIC24EP512GU810
PostPosted: Tue Feb 19, 2019 9:31 am     Reply with quote

I'm trying to get this PIC USB to work. I copied the code and descriptor from a working project (other PIC), but it doesn't work (Error requesting the USB device descriptor, Code 43).

Code:

#include <24EP512GU810.h>
#device ICSP=1
#use delay(osc=24MHZ, clock=48MHZ, USB)

#FUSES NOWDT                   //No Watch Dog Timer
#FUSES CKSFSM                  //Clock Switching is enabled
#FUSES BROWNOUT                
#FUSES NOJTAG                  //JTAG disabled
#FUSES NODEBUG

#define EP1            1

#include <pic24_usb.h>        //Microchip PIC18 hardware layer for usb.c
#include "usb_desc_hid.h"      //USB Device descriptor
#include <usb.c>              
#define SIZE 8

void main( void )
{
    char inbuf[SIZE];
    char outbuf[SIZE];

   usb_init_cs();   
   while(TRUE) {
      usb_task();
      if(usb_enumerated()) {
         if (usb_kbhit(EP1)) {
            usb_get_packet(EP1,inbuf,SIZE);
            if (inbuf[0]==10) {   
               outbuf[0]='o';
               outbuf[1]='k';
               outbuf[2]=0;
            }
            usb_puts(EP1, outbuf, SIZE, 100 );
         }
      }
   }
}


Anybody recognize a mistake?

Or is there something special to consider with this PIC?

Is there a way to measure the oscillator? If you could get the PIC to output to USB with a few lines, you could use an oscilloscope to verify the frequency. This would certainly be a very helpful feature for many developers

Uli
temtronic



Joined: 01 Jul 2010
Posts: 6660
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Feb 19, 2019 10:13 am     Reply with quote

I don't use that PIC but...
this...

#include <pic24_usb.h> //Microchip PIC18 hardware layer for usb.c

seems 'wrong' ? Would the pic24 need a PIC 24 HW layer and not PIC18 HW layer ??

I gave up with embedded USB PICs years ago. It's simpler,easier, cheaper to just buy a TTL<>USB module. I've bought dozens over the years and all have worked without any problems.

Jay
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