|
|
View previous topic :: View next topic |
Author |
Message |
Rorix
Joined: 19 Dec 2009 Posts: 4
|
weird CDC problem |
Posted: Sat Dec 19, 2009 9:57 pm |
|
|
Well here's the thing, I'm currently using CDC function with some LEDs and motors. Here's the issue, from nowhere it stopped working so I'm really confused about this, tried with new PIC ( 18F2550 ) also bought new things (cap , res , board , etc. ) and it's still not working
I'm thinking maybe my fuses are incorrect or something, using 220pf cap and 20MHZ crystal, FYI.
Here's my code:
Code: |
#include <18F2550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,CPUDIV1,VREGEN,PLL5
#use delay(clock=48000000)
#include <usb.h>
#include <usb_cdc.h>
#rom int 0xf00000={1,2,3,4}
void main()
{
delay_ms(300);
usb_cdc_init();
usb_init();
while(TRUE){
output_high(PIN_A0);
delay_ms(2000);
output_low(PIN_A0);
}
while(!usb_cdc_connected()){}
usb_task();
if(usb_enumerated()){
int dato;
dato=usb_cdc_getc();
output_b(dato);
}
else
usb_task();
}
|
When I plug it, it doesn't do anything, not recognized nothing.
But when I use a 4 MHz OSC it is recognized, but I can't install driver on it. Windows Vista 32 bit.
The weird thing is that it worked couple weeks ago.
Thanks |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sun Dec 20, 2009 3:47 am |
|
|
The #fuses look O.K., but the application layout doesn't. E.g. CDC can't connect before the device is enumerated.
You may want to start with a known working CCS example. |
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Sun Dec 20, 2009 7:02 am |
|
|
Rorix wrote: | When I plug it, it doesn't do anything, not recognized nothing. | What do you want your code to do? Code: | while(TRUE){
output_high(PIN_A0);
delay_ms(2000);
output_low(PIN_A0);
} | This code puts it into an endless loop, toggling A0. The CDC part is not entered. Anyway, use a 20MHz crystal, put an LED on A0 and see if it blinks.
usb_task() should be called regularly. Look at the CDC example; modify that to serve your purpose.
Rorix wrote: | when I use a 4 MHz OSC it is recognized, but I can't install driver on it | Make sure you are using the Vista driver, and not the XP driver.
Rohit |
|
|
Rorix
Joined: 19 Dec 2009 Posts: 4
|
|
Posted: Sun Dec 20, 2009 2:16 pm |
|
|
Rohit de Sa wrote: | Rorix wrote: | When I plug it, it doesn't do anything, not recognized nothing. | What do you want your code to do? Code: | while(TRUE){
output_high(PIN_A0);
delay_ms(2000);
output_low(PIN_A0);
} | This code puts it into an endless loop, toggling A0. The CDC part is not entered. Anyway, use a 20MHz crystal, put an LED on A0 and see if it blinks.
usb_task() should be called regularly. Look at the CDC example; modify that to serve your purpose.
Rorix wrote: | when I use a 4 MHz OSC it is recognized, but I can't install driver on it | Make sure you are using the Vista driver, and not the XP driver.
Rohit |
Thanks for answering.
OK I'm using that statement output_high pin A0 just to see if my code is working. Maybe I need to remove the while statement to avoid loop.
Now when I plug it on, the led doesn't turn on nor blinks, and I think it should with or without CDC, so there's my first issue.
Maybe my computer removed driver somehow, or it's corrupted. I should try in a different PC.
thanks |
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Sun Dec 20, 2009 9:25 pm |
|
|
Yep, that's the way to identify and isolate your problem.....one step at a time.
Rorix wrote: | Now when I plug it on, the led doesn't turn on nor blinks, and I think it should with or without CDC | Maybe its a bad crystal? You're right about it blinking with or without CDC.
Rohit |
|
|
aa7dj
Joined: 27 Apr 2007 Posts: 7 Location: St. George, UT
|
|
Posted: Tue Dec 22, 2009 4:58 pm |
|
|
Quote: | using 220pf cap and 20MHZ crystal |
Do you use 220pF with 20 MHz crystal? Better to try 22pF instead.
Hope it will help. |
|
|
Rorix
Joined: 19 Dec 2009 Posts: 4
|
|
Posted: Thu Dec 24, 2009 11:28 am |
|
|
ok new code , new crystal on a new pc and its working without issues thanks to everyone , it was indeed a bad crystal hehe
btw merry xmas |
|
|
nachogb
Joined: 14 Jan 2010 Posts: 2
|
vista driver |
Posted: Thu Jan 14, 2010 9:46 am |
|
|
Rohit wrote: | Make sure you are using the Vista driver, and not the XP driver.
Rohit |
hello,
I have more than less the same problem, where can I find this vista driver you are talking about?
thank you |
|
|
mkuang
Joined: 14 Dec 2007 Posts: 257
|
|
Posted: Thu Jan 14, 2010 9:53 am |
|
|
Rohit de Sa wrote: | Rorix wrote: | When I plug it, it doesn't do anything, not recognized nothing. | What do you want your code to do? Code: | while(TRUE){
output_high(PIN_A0);
delay_ms(2000);
output_low(PIN_A0);
} | This code puts it into an endless loop, toggling A0. The CDC part is not entered. Anyway, use a 20MHz crystal, put an LED on A0 and see if it blinks.
Rohit |
The code is toggling A0 allright, except that A0 is on for 2 seconds and only off for a couple of clock cycles. |
|
|
Ttelmah Guest
|
Re: vista driver |
Posted: Thu Jan 14, 2010 10:13 am |
|
|
nachogb wrote: | Rohit wrote: | Make sure you are using the Vista driver, and not the XP driver.
Rohit |
hello,
I have more than less the same problem, where can I find this vista driver you are talking about?
thank you |
There are two 'XP' compatible install information files that come with the compiler. CDC_NTXP.inf, and CDC_NTXPVista.inf. The problem is that if you try to install with Vista, and just point it at the directory containing both, it'll find the XP one, and fail to install....
Put the Vista compatible one in a separate directory, and point the install at this, and it then works.
Best Wishes |
|
|
nachogb
Joined: 14 Jan 2010 Posts: 2
|
|
Posted: Thu Jan 21, 2010 10:47 am |
|
|
thank you Ttelmah, it seems it works.
kind regards |
|
|
|
|
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
|