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

18f86j50 USB problem

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



Joined: 20 Jan 2012
Posts: 2

View user's profile Send private message

18f86j50 USB problem
PostPosted: Fri Jan 20, 2012 1:58 pm     Reply with quote

it's show "usb not recognize"
HID Mouse --- the cursor must to move in a circle form
This is my code that work on PIC18F4550 But when I change a controller to PIC18F86J50 it doesn't work

my ccs version 4.114
my xtal is 20 MHz
help me plzzz
thank you very much

Code:

#include <18F86j50.h>
#fuses HSPLL,PLL5,NOWDT,NOPROTECT,NOCPUDIV
#use delay(clock=48000000)

#include <pic18_usb.h>
#include <usb_desc_mouse.h>
#include <USB.c>

#byte OSCTUNE = 0xF9B
#bit PLLEN = OSCTUNE.6


void main(void) {
 
   PLLEN = 1;
   delay_ms(10);
  #define MOUSE_SEQUENCE_STEPS  16
   const char mouse_seq[MOUSE_SEQUENCE_STEPS]=
      {0, 1, 3, 4, 4, 4, 3, 1, 0, -1, -3, -4, -4, -4, -3, -1};

   int8 out_data[4];
   unsigned int8 x_seq=0; unsigned int8 y_seq=MOUSE_SEQUENCE_STEPS/4;
   unsigned int8 count=0;


   usb_init_cs();

   while (TRUE) {

      usb_task();

      if (usb_enumerated()) {
         out_data[0]=0; //button state goes here
         out_data[1]=mouse_seq[x_seq];
         out_data[2]=mouse_seq[y_seq];
         out_data[3]=0; //wheel state goes here
         if (usb_put_packet(1,out_data,4,USB_DTS_TOGGLE))
            count++;
         if (count > 10) {
            if (++x_seq>=MOUSE_SEQUENCE_STEPS) {x_seq=0;}
            if (++y_seq>=MOUSE_SEQUENCE_STEPS) {y_seq=0;}
            count=0;
         }
         delay_ms(10);
      }
   }
}
chaowan_jun



Joined: 20 Jan 2012
Posts: 2

View user's profile Send private message

PostPosted: Mon Jan 30, 2012 7:06 am     Reply with quote

Help me please !!!!
temtronic



Joined: 01 Jul 2010
Posts: 9249
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Jan 30, 2012 7:16 am     Reply with quote

Get both datasheets and compare what is different about the two devices.

Have you got the 'Hello World' and 'blinking LED' programs to run on the 2nd device ?

As for the message, if that's from a PC running Windows, odds are you didn't load whatever driver is necessary for the OS to recognize the 'new' USB device( the PIC).
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