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 CCS Technical Support

Unknown USB PIC24FJ64GB

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



Joined: 29 Jun 2014
Posts: 2

View user's profile Send private message

Unknown USB PIC24FJ64GB
PostPosted: Sun Jun 29, 2014 8:59 am     Reply with quote

Hi All,
I work on a device (PIC24FJ64GB) which is controlled by commands sent via USB CDC. VBUS is connect USB +5V, VUSB pull up +3,3V. I debug the program, but usb_enumerated() is never true. Windows will detect the device as an unknown hardware

(I am using CCS Compiler version 5.025)

Thanks in advance
Code:

#include <24FJ64GB004.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES NOJTAG                   //JTAG disabled
#FUSES CKSFSM                   //Clock Switching is enabled, fail Safe clock monitor is enabled

#device ICSP=1

#FUSES HS
#FUSES PR_PLL                   //Primary Oscillator with PLL
#FUSES PLLDIV2

#FUSES PLL96MHZ

#use delay(crystal=8MHz,USB_LOW)
//#use delay(clock=8MHz,crystal=8MHz,USB_LOW,RESTART_WDT)


#include <usb_cdc.h>

int1 usb_connect        = false;     
int1 usb_cdc_oldconnected=FALSE;


void usb_kapcs()
{
 //restart_wdt();
//  if (usb_attached())
//  {
   usb_task();
   if (usb_enumerated())
   {
    if (usb_cdc_carrier.dte_present)
    {
     if (usb_cdc_oldconnected==FALSE)
     {
      usb_cdc_putc("\r\nUSB connect OK!\r\n\r\n");
      delay_ms(50);
//      printf(usb_cdc_putc, "Time of automatic data transmission %X min\r\n",auto_ido);   
      usb_cdc_oldconnected=TRUE;
     }
    usb_connect=true;
    }
    else
    {
     usb_cdc_oldconnected=FALSE;
     usb_connect=false;
    }
   }
   else
   {   
    usb_cdc_oldconnected=FALSE;
    usb_connect=false;
   }
//  }
}

void main()
{
 setup_wdt(WDT_OFF);
 usb_init_cs();
 while(1)
 {
  usb_kapcs();
 } 
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19482

View user's profile Send private message

PostPosted: Sun Jun 29, 2014 9:05 am     Reply with quote

The Windows CDC driver, does not support a low speed USB device. But your clock setup is trying to setup low speed operation. CDC requires the USB to be setup for 'fast'. CDC requires bulk endpoints, which are not allowed for low speed USB operation. The only devices that support low speed are basically HID. There are some third party drivers that implement specific CDC devices with low speed (by cheating), but not the standard drivers.
szecsi



Joined: 29 Jun 2014
Posts: 2

View user's profile Send private message

PostPosted: Sun Jun 29, 2014 9:15 am     Reply with quote

Tthanks for the quick response. I changed the speed
Code:
# use delay (crystal = 8MHz, USB_FAST)

but the error is still the same.
Ttelmah



Joined: 11 Mar 2010
Posts: 19482

View user's profile Send private message

PostPosted: Sun Jun 29, 2014 1:35 pm     Reply with quote

OK.
Why are you using the init_cs, rather than init?.
This will fail if the USB connects, because of your 50mSec delay. With init_cs, the USB interrupt is not used, and usb_task _must_ be called very frequently (faster than perhaps 10mSec).
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