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

PIC18F87J50 USB

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



Joined: 21 Dec 2012
Posts: 5

View user's profile Send private message

PIC18F87J50 USB
PostPosted: Sat May 18, 2013 8:17 am     Reply with quote

I am working with PIC18F87J50 evaluation board (with 12MHz crystal).
I would like to send and receive some data between this board and a PC by USB. I have already tried many examples (based on CDC), but without result. So i think i should try the simplest and the most basic code first. Is there any one to help me ?
temtronic



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

View user's profile Send private message

PostPosted: Sat May 18, 2013 9:07 am     Reply with quote

Well I know the examples that CCS supplies in the 'examples' folder work fine for an 18F4550...
Have you tried them?

hth
jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Sat May 18, 2013 9:37 am     Reply with quote

The CCS CDC examples are as simple as USB gets....

Key things to get right first are:
1) The clock rate. What is your oscillator?. What fuses are you using?.
2) The connections. Common error is getting the D+/D- reversed.
3) Vusb. Remember on this chip you have to supply this.

Best Wishes
jsafaie



Joined: 21 Dec 2012
Posts: 5

View user's profile Send private message

PostPosted: Tue May 21, 2013 9:07 am     Reply with quote

thanks for your replies.
Dear temtronic, yes i have tried it without success.
Dear Ttelmah, because i am using standard evaluation board, i should not have any hardware problem. There is an on-board 12MHz oscillator.
Here is my code:
Code:

#include <18F87J50.h>
#fuses NOWDT, NOXINST, NOPROTECT, HSPLL, PLL3, NOCPUDIV
#use delay(clock=48MHz)
#include <usb_cdc.h>
 
void main(void)
{
   int c;
   usb_cdc_init();
      usb_init();
      usb_wait_for_enumeration();
      while (TRUE)
      {
      usb_task();
                 if(usb_cdc_kbhit()) {
                 c = usb_cdc_getc();
                 printf(usb_cdc_putc, "you typed: %c\r\n", c);
             }
         }
}

The simplest possible program. Now when i connect the board to PC, it is detected as "Unknown USB device". I have tried to install the CCS CDC driver (on win7 64bit), but still the same thing !!!
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Tue May 21, 2013 11:50 am     Reply with quote

Hi,

Are you sure that your PIC is operating at the intended speed? Connect an LED to an I/O pin (thru a suitable current limiting resistor), and turn it On and Off at a predictable rate, say 1 second On and 1 second Off. This simple test will tell you if the PIC is really operating at the speed you think (hope?) it is!

John
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