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

USB malfunction

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



Joined: 21 Jul 2014
Posts: 35

View user's profile Send private message

USB malfunction
PostPosted: Wed Sep 03, 2014 9:18 am     Reply with quote

Hello,

Been struggling with the USB on the 18F45K50. As someone pointed out, I added a connection sense line, and that does work.

Whenever I plug in the USB cable, the PC knows that I have done it, and tells me the USB device has malfunctioned and Windows does not recognize it.

I see some data on the D+ and D- pins with the scope.

I am using CCS's VID and PID and have 'installed' the driver from the Driver folder in the Examples folder.

I have had devices without drivers, and they operate differently. They still make the "ker-clunk" sound, but then tell me they cannot find the proper driver. This is different, with a balloon window popping up on XP.

Any thoughts???

TIA

GlenB K4KV


Here is relevant code:
Code:

#define USB_USE_FULL_SPEED TRUE
#define USB_INTERNAL_PULLUPS TRUE
#FUSES WDT256                   //Watch Dog Timer uses 1:256 Postscale

#use delay(internal=48000000,USB_FULL,ACT=USB)
#use rs232(baud=4800,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=PORT1)

#define USB_CONFIG_VID 0x2405
#define USB_CONFIG_PID 0x000B
#define USB_CONFIG_BUS_POWER 500
#define USB_STRINGS_OVERWRITTEN

char USB_STRING_DESC_OFFSET[]={0,4,12};

char const USB_STRING_DESC[]={...

#include <usb_cdc.h>

main{
   usb_init_cs();
   enable_interrupts(INT_USB);

    for(;;)
    {
        usb_task();
    }
Ttelmah



Joined: 11 Mar 2010
Posts: 19548

View user's profile Send private message

PostPosted: Wed Sep 03, 2014 10:40 am     Reply with quote

I'd open the LST file, and look at the fuses, to see if the compiler is correctly setting up the oscillator. I'd guess not. I'd say that the symptoms are classic for the oscillator not being at the correct frequency, so possibly the ACT is not being enabled, or the wrong PLL is being selected. What compiler version are you on?. I've always been 'explicit' with setting fuses myself for the clock.

Best Wishes
gfbankston



Joined: 21 Jul 2014
Posts: 35

View user's profile Send private message

fuses
PostPosted: Wed Sep 03, 2014 5:03 pm     Reply with quote

Thanks, I will check the fuses!

BTW, the CCS usb cdc serial2 example does not work, with the PC not responding at all. I suspect the internal pullup is not enabled!

Glen
gfbankston



Joined: 21 Jul 2014
Posts: 35

View user's profile Send private message

compiler
PostPosted: Wed Sep 03, 2014 6:34 pm     Reply with quote

latest version of the compiler...
gfbankston



Joined: 21 Jul 2014
Posts: 35

View user's profile Send private message

fuses
PostPosted: Thu Sep 04, 2014 7:27 am     Reply with quote

I did not find anything wrong with the fuses:
/*
Configuration Fuses:
Word 1: C82B PLL3X PLLEN CPUDIV2 LS48MHZ INTRC_IO PRIMARY_SW FCMEN IESO
Word 2: 2059 NOPUT NOBROWNOUT BORV19 NOLPBOR NOWDT WDT256
Word 3: D300 CCP2C1 PBADEN T3CKC0 SDOB3 NOMCLR
Word 4: 0020 NOSTVREN NOLVP ICSP2 NOXINST DEBUG
Word 5: C00F NOPROTECT NOCPB NOCPD
Word 6: E00F NOWRT NOWRTC NOWRTB NOWRTD
Word 7: 400F NOEBTR NOEBTRB
*/

OSCCON = 0x70
verified oscillator output at 6Mhz on pin.

Finally got CCS serial2 example code to show the same malfunction by adding #define USB_INTERNAL_PULLUPS TRUE
ACTCON =0x90 (enabled with USB source)

Next, I guess I will try Low Speed USB...

GlenB
Ttelmah



Joined: 11 Mar 2010
Posts: 19548

View user's profile Send private message

PostPosted: Thu Sep 04, 2014 8:51 am     Reply with quote

CPUDIV2????.

Think about it NOCPUDIV gives 48MHz from the 96MHz PLL. How can CPUDIV2 be right?.
gfbankston



Joined: 21 Jul 2014
Posts: 35

View user's profile Send private message

max speed
PostPosted: Thu Sep 04, 2014 10:37 am     Reply with quote

This chip 45k50 and the 25K50, which I am also using, have a 16Mhz internal osc. x3 yields 48Mhz (the clock necessary for USB full speed) and DIV2 yields
24Mhz which gives me a 6Mhz instruction cycle.

OK?

BTW, just tried the usb_cdc code on another board with a 25K50 and it worked. It recognized the usb and reported the model number string, but could not find the driver. Manually told it where the CCS driver was and it
installed, no problem...

It is a much simpler board than the one with the 45K50 on it, but I do not
see why the hardware connected to the chip should make any difference!

GlenB
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 04, 2014 11:11 am     Reply with quote

The only way I can get something close to your reported fuses is if
I do this:
Quote:
#include <18F45K50.h>
#FUSES WDT256
#use delay(internal=24000000,USB_FULL,ACT=USB)

Then I get your reported fuses:
Quote:
Word 1: C82B PLL3X PLLEN CPUDIV2 LS48MHZ INTRC_IO PRIMARY_SW FCMEN IESO


If I put 48 MHz in the #use delay() like you have, the fuses are shown
in the .LST file as:
Quote:
Word 1: C823 PLL3X PLLEN NOCPUDIV LS48MHZ INTRC_IO PRIMARY_SW FCMEN IESO


So there is something wrong, or something you are not telling us.
Ttelmah



Joined: 11 Mar 2010
Posts: 19548

View user's profile Send private message

PostPosted: Thu Sep 04, 2014 11:13 am     Reply with quote

Exactly.

His original post shows the chip supposedly clocking at 48MHz, but the fuses he shows would not give this.
gfbankston



Joined: 21 Jul 2014
Posts: 35

View user's profile Send private message

speed
PostPosted: Thu Sep 04, 2014 2:07 pm     Reply with quote

I searched the data sheet and 96Mhz is not in the document. 48Mhz is the
highest speed listed or mentioned in the data sheet.

#use delay(clock=24000000,internal=48000000,USB_FULL,ACT=USB)

is one of the things I tried, yielding the following config:
Word 1: C82B PLL3X PLLEN CPUDIV2 LS48MHZ INTRC_IO PRIMARY_SW FCMEN IESO

#use delay(internal=24000000,USB_FULL,ACT=USB)
yields:
Word 1: C82B PLL3X PLLEN CPUDIV2 LS48MHZ INTRC_IO PRIMARY_SW FCMEN IESO

#use delay(internal=48000000,USB_FULL,ACT=USB)
yields:

Word 1: C823 PLL3X PLLEN NOCPUDIV LS48MHZ INTRC_IO PRIMARY_SW FCMEN IESO
which runs the instruction clock at 12Mhz.

The problem is board specific, since the software now works on another board with a 25K50 on it.
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