View previous topic :: View next topic |
Author |
Message |
jsafaie
Joined: 21 Dec 2012 Posts: 5
|
PIC18F87J50 USB |
Posted: Sat May 18, 2013 8:17 am |
|
|
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: 9243 Location: Greensville,Ontario
|
|
Posted: Sat May 18, 2013 9:07 am |
|
|
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: 19538
|
|
Posted: Sat May 18, 2013 9:37 am |
|
|
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
|
|
Posted: Tue May 21, 2013 9:07 am |
|
|
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
|
|
Posted: Tue May 21, 2013 11:50 am |
|
|
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 |
|
|
|