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 on PIC18F26J50

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



Joined: 11 Nov 2003
Posts: 118

View user's profile Send private message

USB on PIC18F26J50
PostPosted: Mon May 10, 2010 9:28 am     Reply with quote

Just put some code together to use USB on the PIC18F26J50. It is basically just the ex_usb_serial2.c example code included with PCWH, but without the debug code and eeprom. I get a connection with my Windows 7 (64-bit) computer want will find the "SERIAL DEMO" in "Other devices" in my Device manager. No driver is being detected. The Example code indicates that Windows with detect a generic driver to use as a COM. I cannot find a compatible driver.

Here is my code.

Code:
#include <18F26J50.h>

#device adc=10

#FUSES NODEBUG             
#FUSES NOXINST                  
#FUSES STVREN           
#FUSES PRIMARY               

#FUSES PLLDIV2   
#FUSES NOWDT                    

//#FUSES CPUDIV6
#FUSES NOCPUDIV 
#FUSES PROTECT   

#FUSES NOIESO         
#FUSES NOFCMEN               
#FUSES NOLPT1OSC             
#FUSES NOT1DIG 
#FUSES INTRC_PLL_IO             
//#FUSES INTRC_IO                 

#FUSES WDT128                   

#FUSES RTCOSC_T1
#FUSES DSWDTOSC_INT         
#FUSES NODSWDT                 
#FUSES NODSBOR   
#FUSES DSWDT2147483648

#FUSES MSSPMSK7
#FUSES NOIOL1WAY           

#FUSES NOWPCFG
#FUSES WPFP
#FUSES WPEND                 
#FUSES WPDIS

#use delay(clock=48000000) 

  #ZERO_RAM
  #include <stdio.h>
  #include <stdlib.h>
  #define USB_CON_SENSE_PIN PIN_C2  //Voltage level converted
  #include <usb_cdc.h>
  #include "defines.c"            //all defines
 

#define a_dir  0x5B   //directional running
#define a_dirs 0x5B   //directional sleep
#define a_def 0x00

#define b_dir 0xF6   //directional running
#define b_dirs 0xF6   //directional sleep
#define b_def 0x00

#define c_dir 0x4E   //directional running
#define c_dirs 0x4E   //directional sleep   
#define c_def 0x00

/************ Main ****************/

void main()
{
   int i, j, address, value;
   
   setup_adc(ADC_OFF);   //disable ADC
   
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL | RTCC_DIV_4);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   setup_oscillator(OSC_8MHZ|OSC_NORMAL|OSC_PLL_ON|OSC_IDLE_MODE);
 
   set_tris_a(a_dirs);                           //settup port directions
   set_tris_b(b_dirs);
   port_b_pullups(FALSE);            //Don't need pull ups
   set_tris_c(c_dirs);
   
   port_a = a_def;                              //default pin states
   port_b = b_def;
   port_c = c_def;
   
   enable_interrupts(GLOBAL);
   
   usb_init_cs();
   
   while(1)
   {
   output_bit(sleepf,0);   //sleep
      
      usb_task();
     
      if (usb_enumerated())
      {
         if (usb_cdc_kbhit())
         {
            /****do not want to divulge too much code*****/
         }
      }
   }         
}


I also tried using the following with no luck:

Code:
#FUSES CPUDIV2
#use delay(clock=24000000)
#define USB_USE_FULL_SPEED 0


If I try to look in the PICC CCS install directory, a USB to UART driver is found but cannot starts device (error code 10).

Any help would be appreciated.

-Matt
_________________
-Matt


Last edited by DragonPIC on Mon May 10, 2010 9:46 am; edited 1 time in total
DragonPIC



Joined: 11 Nov 2003
Posts: 118

View user's profile Send private message

PostPosted: Mon May 10, 2010 9:35 am     Reply with quote

Another look and the only difference between the high and low speed setting I listed above is that Windows device manager actually changed the name from SERIAL DEMO to "USB to UART" in low speed. So maybe something worked better in low-speed. Still have the exclamation point next to it though.
_________________
-Matt
Ttelmah



Joined: 11 Mar 2010
Posts: 19545

View user's profile Send private message

PostPosted: Mon May 10, 2010 3:00 pm     Reply with quote

INT_RC, _only_ supports low speed operation. It is not accurate enough for high speed (in the data sheet....). Section 2.4:
"The high accuracy of the INTOSC will allow the application to meet low-speed USB signal rate specifications.".
Note the use of 'low speed' here.

Then do a search here. Patches have been posted for the standard .inf file to make it work in W7 64bit. By default it won't.

Best Wishes
DragonPIC



Joined: 11 Nov 2003
Posts: 118

View user's profile Send private message

Speed
PostPosted: Mon May 10, 2010 4:40 pm     Reply with quote

Yes, I seen someone mention the speed issue in another post. I figure I'd give it a shot since it was listed as an option in table 2-5. Wink
Windows did seem to at least kind of recognize it though.

Anyway, that's not a problem for me since I probably won't need all that speed. That is why I tried out the low speed configuration.

I also found the cdc_NTXPVista.inf and had no luck (unless Windows 7 isn't reading my updated file). Looking at the driver CCS gave (dated the same as the post with that fix) it seemed to have the support for it. My driver seems to be dated the same as that post (1/15/2010). Mine reads:
Code:

[Manufacturer]
%CCS%=CCS,NTamd64

[CCS]
%CCS_CDC%=Reader, USB\VID_0461&PID_0033
%CCS_CDCBOOT%=Reader, USB\VID_0461&PID_0034

[CCS.NTamd64]
%CCS_CDC%=Reader, USB\VID_0461&PID_0033
%CCS_CDCBOOT%=Reader, USB\VID_0461&PID_0034

[Reader_Install.NTx86]
;Windows2000

I'll give it another shot though.

Thanks Ttelmah,

Matt
_________________
-Matt
DragonPIC



Joined: 11 Nov 2003
Posts: 118

View user's profile Send private message

PostPosted: Tue May 11, 2010 12:21 pm     Reply with quote

I got a chance to go back to a Windows 2000 32-bit computer and everything seems to be working fine on there if I use the low-speed configuration. There must be something wrong with the Windows 7 64-bit driver.
_________________
-Matt
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