USB Problem

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
User avatar
Coccoliso
Posts: 152
Joined: Mon Feb 17, 2014 10:34 am

USB Problem

Post by Coccoliso » Fri Apr 04, 2014 4:02 pm

Hello,
I just started to test the USB and I saw that it refers to the version SFUSBv142.
I tried to compile main_hid_SFtest.bas on a 18F4458 and I will generate the error

"The ordinal Constant expression expected"

followed by 2 errors

"Identifier Not Declared: TXReportRAM"

and

"Identifier Not Declared: RXReportRAM."

The 18F4458 has the dual ram (1-Kbyte Dual Access RAM for USB).
Where am I doing wrong?
Is there any particular OPTION to set?
Thank you.

Jerry Messina
Swordfish Developer
Posts: 1469
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: USB Problem

Post by Jerry Messina » Fri Apr 04, 2014 7:22 pm

Sorry... some of the definitions were changed after that example file was written.

TXReportRAM and RXReportRAM became TX_Report_RAM and RX_Report_RAM

Try using this instead...

Code: Select all

//
//-------------------------------------------------------------
// USB report structures
//-------------------------------------------------------------
//
// TX report...
structure TTXReport
   Time as word
   Message as string
end structure

dim TXReport as TTXReport absolute TX_Report_RAM

// RX report...
structure TRXReport
   LED0 as bit
   LED1 as bit
end structure

dim RXReport as TRXReport absolute RX_Report_RAM

User avatar
Coccoliso
Posts: 152
Joined: Mon Feb 17, 2014 10:34 am

Re: USB Problem

Post by Coccoliso » Fri Apr 04, 2014 10:27 pm

OK :wink: !
still a small request ..
I mounted a quartz 12MHz while the example is with a 24MHz quartz.
The device is found, the PC searches for the driver "HID Swordfish" but after installing it HID does not seem to respond correctly and becomes "Unknown device".
The configuration seems correct for 12MHz xtal ?

Code: Select all

Device = 18F4458 ' 2553
Clock = 48

Config
    FOSC = HSPLL_HS,        
'    PLLDIV = 6,
    PLLDIV = 3,
    CPUDIV = OSC1_PLL2,   
    USBDIV = 2,            
    FCMEN = OFF,
    IESO = OFF,
    PWRT = ON,
    BOR = OFF,
    BORV = 2,
    VREGEN = ON,
    WDT = OFF,
    WDTPS = 2048,
    CCP2MX = OFF,
    PBADEN = OFF,
    LPT1OSC = OFF,
'    MCLRE = ON,
    MCLRE = OFF,
    STVREN = ON,
    LVP = OFF,
    XINST = OFF,
    DEBUG = OFF

Jerry Messina
Swordfish Developer
Posts: 1469
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: USB Problem

Post by Jerry Messina » Fri Apr 04, 2014 11:50 pm

That looks like the right setup for a 12MHz xtal

User avatar
Coccoliso
Posts: 152
Joined: Mon Feb 17, 2014 10:34 am

Re: USB Problem

Post by Coccoliso » Sat Apr 05, 2014 9:48 am

Noise on Vcc dumped with extra 220nF capacitor and 220nF to 470nF capacitor on VUSB pin.
In some circuits there are 2 x 330 ohm resistors in series on D+ and D- lines for protection I think :roll: ..
I removed this resistors otherwise sometimes PC does not recognize the hardware.
:lol: ALL OK !

Post Reply