|
|
View previous topic :: View next topic |
Author |
Message |
dgg91
Joined: 14 Nov 2015 Posts: 8
|
PIC18LF4550 not recognized - USB comm [SOLVED] |
Posted: Mon Jan 11, 2016 9:20 am |
|
|
First of all the mcu is the LF version but i think its full compatible with 18f4550.
So I'm trying to communicate via usb but windows wont recognize the device.
I checked the hardware, D+ & D- are OK connected, VUSB+330nf capacitor to GND - this pin shows 3.3V- and VDD-VSS are also connected across a 100nF cap.
Still windows showing unknown device every time i connect the board to PC.
So maybe it's a software problem: This is my code so far:
I'm using 20Mhz external crystal.
Code: |
#include <18F4550.h>
#fuses HSPLL,USBDIV,PLL5,VREGEN,NOWDT,NOPROTECT,NOLVP,DEBUG,CPUDIV1
#device ADC=10
#use delay(clock=12M)
#DEFINE USB_HID_DEVICE TRUE
#define USB_EP1_TX_ENABLE USB_ENABLE_INTERRUPT //turn on EP1 for IN bulk/interrupt transfers
#define USB_EP1_TX_SIZE 10
#define USB_EP1_RX_ENABLE USB_ENABLE_INTERRUPT //turn on EP1 for OUT bulk/interrupt transfers
#define USB_EP1_RX_SIZE 2
#use STANDARD_IO(b)
#include <pic18_usb.h>
#include <usb_desc_hid.h>
#include <usb.c>
int8 output[8];
int8 input1[2];
int16 signal;
void main() {
setup_adc_ports(ALL_ANALOG | VREF_VREF); //);
setup_adc(ADC_CLOCK_INTERNAL);
usb_init();
delay_ms(50);
//============================================================================================
// main loop
//============================================================================================
while (TRUE)
{
usb_task();
//============================================================================================
// input
//============================================================================================
if (usb_kbhit(1))
{
usb_get_packet(1,input1,2);
}
//============================================================================================
// output
//============================================================================================ if (usb_enumerated())
{
// .......... A/D conversions ...........
usb_put_packet(1, output, 8, USB_DTS_TOGGLE);
}
}
|
Last edited by dgg91 on Thu Jan 14, 2016 6:57 am; edited 1 time in total |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Mon Jan 11, 2016 9:26 am |
|
|
hmm... which version of Windows ?
What Windows software are you using ?
Did you install the file mentioned in the comments in the USB driver ?
can't tell you which one...I gave up on the 4550, far easier/cheaper to use USB<>TTL modules, at least here in Canada,eh !!
Jay |
|
|
dgg91
Joined: 14 Nov 2015 Posts: 8
|
|
Posted: Mon Jan 11, 2016 9:33 am |
|
|
I'm using W7 64 bits.
i didn't still any driver because windows won't even recognize the device. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Mon Jan 11, 2016 10:25 am |
|
|
First your oscillator settings are wrong.
Code: |
#fuses HSPLL,USBDIV,PLL5,VREGEN,NOWDT,NOPROTECT,NOLVP,DEBUG,CPUDIV1
#device ADC=10
#use delay(clock=12M)
|
PLL5, implies you have a 20MHz crystal (since the PLL requires 4MHz). Do you?.
Then you are selecting HSPLL which says to feed the CPU from the USB PLL, and CPUDIV1, which means the CPU will be running off 96MHz/2 = 48MHz. Not 12MHz....
Then you say you are using the LF4550. What is your supply voltage?. You say it has 3.3v, but the internal regulator _requires_ 4.1v minimum as Vdd, to give a reliable supply. The point about the LF chip is you can run at lower voltages by feeding Vusb yourself. If the supply is below 4.1v, then the USB transmission will become unreliable as the Vusb will droop when the transceivers start to drive. You have the regulator 'on' which suggests you are using this, so what is your supply voltage?. |
|
|
dgg91
Joined: 14 Nov 2015 Posts: 8
|
|
Posted: Mon Jan 11, 2016 10:43 am |
|
|
I'm using 20Mhz external crystal.
The board is bus powered only, +5V from the usb. I'm using the LF version because its the one I have but since the supply is +5V i think it should operate like the 'F' version.
So since Vdd is +5v I assume that i can use the internal reg and i don't need to supply VUSB with 3.3v.
I checked that pin, VUSB, and it shows 3.3V , still Windows won't recognize my device.
Do i need to install any drivers or something? |
|
|
drolleman
Joined: 03 Feb 2011 Posts: 116
|
|
Posted: Mon Jan 11, 2016 11:44 pm |
|
|
if you are seeing "device not recognized" it is still hardware related. you may have a 20mhz crystal but you state the delay at 12mhz. if you have a scope now is the time to get it out. you may think you have good connections but all you need is 1 bad one and it won't work, and it won't tell you witch one is bad. you can download UVCViewx86.exe to show what usb devices are connected to your system. this is for hardware only no drivers are needed.
just a few ideas
dave |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Tue Jan 12, 2016 2:00 am |
|
|
OK. First fix your clock rate.
Then add more capacitance at the PIC. 0.1uF, is not sufficient to run a PIC 'bus powered'. A PIC should always have as a minimum 0.1uF immediately adjacent to each pair of supply pins, and then whatever else is needed to smooth the supply before it is delivered to these points. Microchip has a recommended circuit for 'bus powered', and it 10uF/16v in parallel with two 0.1uF ceramic capacitors.
Then how are the USB connections actually wired?. Wire length, track capacitance etc.. These are high frequency signals. the two lines must be close to the same length, and you have to be careful about capacitance between the lines and from the lines to ground. No more than about 50mm long from the connector to the chip. If your lines are a little long, or you are not sure about the capacitance, add a 22R resistor 'in line' into each of the signals, as they enter the board (reduces problems from mismatch).
Have you checked your PIC actually is running?.
Then look at the HID example. You must check for enumerated _before_ checking for kbhit.
ADC_CLOCK_INTERNAL is not recommended above 1MHz. Minor, but correct it.
Get the demo running first. |
|
|
dgg91
Joined: 14 Nov 2015 Posts: 8
|
|
Posted: Tue Jan 12, 2016 5:50 am |
|
|
I already have a 4.7 uF electrolytic capacitor near the connector, i read that 10uF its the limit for usb communication so i went for a lower value
Wire lenght 1m, both the connector and D+&D- are close to the MCU
PIC is running, i checked it modifying some pin values before usb_init() and then after
I used the UVCView for windows and this is the report
Code: | ---===>Device Information<===---
ConnectionStatus: FailedEnumeration
Current Config Value: 0x00 -> Device Bus Speed: Low
Device Address: 0x00
Open Pipes: 0
*!*ERROR: No open pipes!
===>Device Descriptor<===
*!*ERROR: bLength of 0 incorrect, should be 18
bLength: 0x00
bDescriptorType: 0x00
bcdUSB: 0x0000
bDeviceClass: 0x00
*!*ERROR: Device enumeration failure |
So its a enumeration problem i think, but it also shows a device speed LOW when its supposed to be HIGH or FULL?
I'll try to:
- fix the clock rate
- check the crystal with an oscilloscope
- run the HID demo
thanks for your help |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Tue Jan 12, 2016 5:59 am |
|
|
Have you checked the _speed_ the PIC is running.
Do a 'flash an LED' test, and verify that when you specify one second to flash the LED does flash for one second.
This need to be right, before anything else.
Then use the example first. You are missing the USB_FULL setting in your configuration, so the code will default to trying to setup low speed USB. HID can be low speed so this won't stop it enumerating. |
|
|
dgg91
Joined: 14 Nov 2015 Posts: 8
|
|
Posted: Thu Jan 14, 2016 6:56 am |
|
|
The speed was OK, the problem was a bad connection in D+.
Got it to work, thanks for your help. |
|
|
|
|
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
|