|
|
View previous topic :: View next topic |
Author |
Message |
MUHAMMAD_T
Joined: 15 Sep 2012 Posts: 3 Location: GIZA/EGYPT
|
PIC18F4550 USB Problem |
Posted: Sat Sep 15, 2012 7:32 am |
|
|
I have made my own USB library, because i needed to use it with PIC and ATMEL chips. I'm testing it on the 18F4550 chip and it works just fine on ISIS Proteus, but when I plug the hardware into the PC, it gives unknown device notification. The USB does not even reset . The hardware is very simple so that I just need to enumerate the USB, all required capacitors are in position. Anyone can tell what to do?! _________________ "EGYPT is not a country in which we live , EGYPT is a place that lives in us" |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Sat Sep 15, 2012 9:28 am |
|
|
The odds are frequency.
Proteus has no idea what frequency your oscillator or dividers gives, relying on _you_ telling it. The real PIC instead needs these to be right.
Also the Proteus USB library _is_ faulty. This is part of the reason for the post at the top of this forum saying 'no Proteus questions', because it will allow you to configure systems as 'OK', that can never work, and conversely will tell you something is OK, which isn't....
Other oter thing, Proteus does not handle correctly the capacitor on Vusb. You say 'all required capacitors r in position', but Proteus will accept capacitors on Vusb, that won't work on the real chip. You want something like a 0.22uF, or 0.47uF polyester _not_ an electrolytic.
As a comment, are you using sensing on Vusb?. Technically, this is actually _required_ by the USB spec, with this requiring the peripheral to not wake up on the bus, until this line is seen, but a lot of the 'demo' programs allow you to not use this, which can cause problems in the real world.
Post your fuses, and what crystal you are using.
Best Wishes |
|
|
MUHAMMAD_T
Joined: 15 Sep 2012 Posts: 3 Location: GIZA/EGYPT
|
|
Posted: Sat Sep 15, 2012 9:56 am |
|
|
Well, the compiler is CCS, and I'm not using the built in library. I made my own. I use interrupt, not polling, which is safer I guess. The fuses are:
Code: |
HSPLL, PLL1,USBDIV, CPUDIV1,VREGEN, NOBROWNOUT, NOLVP,PUT,MCLR,NOWDT , NODEBUG |
The crystal is 4MHz, crystal caps are 22pF. I'm operating in Bus Powered mode and the Vbus gives the right 3.3V on the 470nF cap.
I think the problem is not in the hardware, because I use very simple schematic which is very popular for USB. The problem is not in enumeration because it does not even reset. I'm tracking the Reset ISR by outputting some value on PORT B, and it does not give this value, which means it does not reset.
ANY IDEAS ?
Thx in Advance
and Thx Ttelmah for your response. _________________ "EGYPT is not a country in which we live , EGYPT is a place that lives in us" |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Sat Sep 15, 2012 2:52 pm |
|
|
Honestly if the hardware is all ok...use the CCS supplied USB test programs in the examples folder. I _know_ that they do work.
Once you confirm that your hardware works with the CCS USB programs,then install your code and see what happens.
hth
jay |
|
|
MUHAMMAD_T
Joined: 15 Sep 2012 Posts: 3 Location: GIZA/EGYPT
|
|
Posted: Sat Sep 15, 2012 2:56 pm |
|
|
I did that with the ex_usb_hid, and the problem was the same. Well, if you can supply a schematic just for enumeration, and a TESTED code that you made and it worked, I would be thankful. Thx in advance.
THX temtronic for replying. _________________ "EGYPT is not a country in which we live , EGYPT is a place that lives in us" |
|
|
drolleman
Joined: 03 Feb 2011 Posts: 116
|
|
Posted: Sat Sep 15, 2012 3:03 pm |
|
|
You need to do the work.
If the ccs example didn't work, your hardware is not correct.
Start there... |
|
|
Avinash P
Joined: 21 Nov 2012 Posts: 3
|
|
Posted: Wed Nov 21, 2012 10:44 pm |
|
|
I have developed a program to interface PIC18F4550 with PC using USB.
The code shows 18 errors, Please help me to resolve the issue.
My code:
Code: |
#include <main.h>
#include <stdio.h>
#include <stdlib.h>
#include <USB.h>
#include <pic18_usb.h>
#include <usb.c>
#include <lcd.c>
#byte PORTA=0xF80
#byte PORTB=0xF81
#byte PORTC=0xF82
#byte PORTD=0xF83
#byte PORTE=0xF84
#byte TRISA=0xF92
#byte TRISB=0xF93
#byte TRISC=0xF94
#byte TRISD=0xF95
#byte TRISE=0xF96
//#bit USB_CON_SENSE_PIN=0xF82.0
int8 ATTACHED,ENUMERATED;
char dat;
void main()
{
setup_timer_3(T3_DISABLED | T3_DIV_BY_1);
TRISC=0x00F;
dat=100;
lcd_init();
usb_init_cs();
while(TRUE)
{
ATTACHED = usb_attached(); //checking whether USB attached to port
if(ATTACHED && TRUE)
{
usb_task();
if(ENUMERATED && TRUE)
{
usb_puts(0,dat,8,100);
}
} //TODO: User Code
}
} |
ERRORS on compiling
Undefined identifier USB_NUM_INTERFACES
Undefined identifier USB_TOTAL_CONFIG_LEN
Undefined identifier USB_STRING_DESC_OFFSET
Undefined identifier USB_STRING_DESC
Undefined identifier USB_CLASS_DESCRIPTORS
Undefined identifier USB_CONFIG_DESC
Undefined identifier USB_CLASS_SPECIFIC_DESC_LOOKUP
Undefined identifier USB_CLASS_SPECIFIC_DESC_LOOKUP_SIZE
Undefined identifier USB_CONFIG_DESC
Undefined identifier USB_CLASS_SPECIFIC_DESC
Undefined identifier USB_STRING_DESC
Undefined identifier USB_DEVICE_DESC
Warnings
Duplicate #define
Please help me to resolve this issue. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Thu Nov 22, 2012 2:10 am |
|
|
Comment in the code:
Code: |
#include <main.h>
#include <stdio.h>
#include <stdlib.h>
#include <USB.h> //not needed
#include <pic18_usb.h>//not needed
#include <usb.c>//not needed
#include <lcd.c>//not needed
//Start here. You are loading the USB drivers, _but no descriptor_. USB won't work without a descriptor. Notice how most of your errors have 'DESC' in them......
//Just load 'usb_cdc.h'. Nothing else. This loads the CDC descriptor, and automatically loads the drivers as well. - remove all the lines marked as 'not needed'. Or use usb_hid etc., depending on what type of USB device you are trying to create.
#byte PORTA=0xF80
#byte PORTB=0xF81
#byte PORTC=0xF82
#byte PORTD=0xF83
#byte PORTE=0xF84
#byte TRISA=0xF92
#byte TRISB=0xF93
#byte TRISC=0xF94
#byte TRISD=0xF95
#byte TRISE=0xF96
//All of the above are pointless. CCS, gives you input and output functions for the ports, and tris functions for the ports. Remove the above eleven lines...
//#bit USB_CON_SENSE_PIN=0xF82.0
//This would need to be above the USB driver being loaded. Syntax is wrong as well CCS wants the pin #defined as a pin name.
int8 ATTACHED,ENUMERATED;
//Why int8?. int1 is much more compact. Not needed anyway....
//Generally don't use capitals for variable names. Standard 'C' convention is to reserve 'all capitals' for macros (defines), allowing you to know that these are being used.
char dat;
void main()
{
setup_timer_3(T3_DISABLED | T3_DIV_BY_1);
TRISC=0x00F;
//Not wanted/needed. Unless you are specifically overriding the default behaviour, let CCS handle the TRIS registers for you.
dat=100;
lcd_init();
usb_init_cs();
while(TRUE)
{
ATTACHED = usb_attached(); //checking whether USB attached to port
if(ATTACHED && TRUE)
//Pointless. Just use : if (usb_attached()) you are wasting instructions and storage space....
{
usb_task();
if(ENUMERATED && TRUE)
//even worse. You have not put anything into 'ENUMERATED'....
//if(usb_enumerated())
{
usb_puts(0,dat,8,100);
}
} //TODO: User Code
}
}
|
General comment, avoid 'hard wiring' things to pin numbers, use the symbolic names. Makes it much safer, and easier to use if you change chips.
Best Wishes |
|
|
Avinash P
Joined: 21 Nov 2012 Posts: 3
|
Thanks for your fast reply |
Posted: Thu Nov 22, 2012 3:45 am |
|
|
I have tried the changes mentioned by you.
Now all my errors are cleared.
Going to fuse the program!
Once again my sincere thanks. |
|
|
Avinash P
Joined: 21 Nov 2012 Posts: 3
|
PIC18F4550 USB |
Posted: Mon Nov 26, 2012 2:50 am |
|
|
hi,
i am testing my hardware now, my hardware is got powered by USB by its not detected by PC,
whether i need to implement On the Go protocol in my pc or the problem may be with my code or hardware ?
MY EDITED CODE
#include <main.h>
#include <stdio.h>
#include <stdlib.h>
#include <usb_cdc.h>
//#include <USB.h>
//#include <pic18_usb.h>
//#include <usb.c>
#include <lcd.c>
#byte PORTA=0xF80
#byte PORTB=0xF81
#byte PORTC=0xF82
#byte PORTD=0xF83
#byte PORTE=0xF84
#byte TRISA=0xF92
#byte TRISB=0xF93
#byte TRISC=0xF94
#byte TRISD=0xF95
#byte TRISE=0xF96
#define USB_CON_SENSE_PIN PIN_B2
char dat;
void main()
{
setup_timer_3(T3_DISABLED | T3_DIV_BY_1);
TRISB=0x00F;
dat=100;
lcd_init();
usb_init();
while(TRUE)
{
if(usb_attached())
{
lcd_putc("\f USB DETECTED");
delay_ms(100);
usb_task();
if(usb_enumerated())
{
lcd_putc("\f USB ENUMERATED");
usb_puts(0,dat,8,100);
}
delay_ms(100);
} //TODO: User Code
}
}
pls help me
Thanks in advance |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Mon Nov 26, 2012 6:23 am |
|
|
Honestly, you _must_ install the CCS USB example programs and confirm they work with your hardware.
1) you do not need OTG(OnTheGo) USB to make a 4550 work with a PC.
2) hardware...do you have the correct 'sense' resistors/hardware for the 4550?
3) PS side...correct 'driver' installed and running , have you tried USBVIEW.exe?
Anyone trying to help you will have first installed and tested the CCS supplied examples as we KNOW they WORK.USB is NOT easy or simple.
Your code might be ok...but have a bad hardware setup...
Your code could be bad...and have a hardware problem..
Your code can either be right or wrong but your PC software is bad...
There are too many choices for anyone here to say 'this' is the 'problem'.
Please , install the CCS USB examples and reply with the reults, then we can narrow down what's going on.
hth
jay |
|
|
|
|
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
|