View previous topic :: View next topic |
Author |
Message |
szecsi
Joined: 29 Jun 2014 Posts: 2
|
Unknown USB PIC24FJ64GB |
Posted: Sun Jun 29, 2014 8:59 am |
|
|
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
|
|
Posted: Sun Jun 29, 2014 9:05 am |
|
|
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
|
|
Posted: Sun Jun 29, 2014 9:15 am |
|
|
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
|
|
Posted: Sun Jun 29, 2014 1:35 pm |
|
|
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). |
|
|
|