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 support@ccsinfo.com

usb_init() problem

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



Joined: 31 Dec 2010
Posts: 3
Location: BR

View user's profile Send private message

usb_init() problem
PostPosted: Sun Oct 23, 2011 10:31 am     Reply with quote

Hi all,

I am trying to use the the PIC18f4550 to produce a virtual com port.

The code is:

main.c
Code:

#include <main.h>
#include <usb_cdc.h>

void main()
{
output_high(PIN_B0);
usb_cdc_init();
usb_init();

   while(!usb_cdc_connected()) {}
   
   while(true)
   {       
    output_high(PIN_B1);

       usb_task();
       if (usb_enumerated()) {
       printf(usb_cdc_putc, "ola");
       }
        output_high(PIN_B2);     
   }
}

main.h

Code:


#include <18F4550.h>
#device adc=16

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES PLL1                     //No PLL PreScaler
//#FUSES CPUDIV2                  //System Clock by 2
//#FUSES INTRC                    //Internal RC Osc
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)

#use delay(crystal=4000000)


But just the PIN_B0 go high and the windows don't recognize the serial port.

Has any error in the code ? Could be hardware ? ( I am using a breadboard )
temtronic



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

View user's profile Send private message

PostPosted: Sun Oct 23, 2011 12:46 pm     Reply with quote

You're best to use the example in the examples folder first before you go 'out on your own'.

I currently have a breadboarded PIC18F4550 running at 48MHz without any problems.

I'm running windows XP PRO and once the driver was installed( the dotINF file) Windows was happy...
also be sure that D+ and D- are correct.
Ttelmah



Joined: 11 Mar 2010
Posts: 19369

View user's profile Send private message

PostPosted: Sun Oct 23, 2011 2:46 pm     Reply with quote

and that Vusb is properly smoothed.

Big one though. the fuses are not there to turn on the USB Vreg, and select the USB clock source. Otherwise USB is not going to work, unless you feed 3.3vv to Vusb.
You need USBDIV, and VREGEN in the fuses to have any hope.
It should then be seen.

However 4MHz as the CPU clock, is 'pushing it'. You may well find that you will have problems with this. 8MHz is probably OK, but in the past, dropping the frequency 'too low', gives unreliable operation, and 4MHz falls into this area.

There is also a 'caveat', that the PLL, can sometimes be unreliable off 4Mhz crystals, being very critical on drive levels. 8MHz is much safer, or you may have to add a series resistor to get reliable operation.

Remember you can run the USB off the crystal, and the CPU off the internal RC at 8Mhz if required.

Best Wishes
biozit



Joined: 31 Dec 2010
Posts: 3
Location: BR

View user's profile Send private message

PostPosted: Sun Oct 23, 2011 4:07 pm     Reply with quote

Thanks for the help Ttelmah and temtronic,


I checked the D+ and D-.

Now i trying with a crystal 26 Mhz and the example ex_usb_serial2.c.


What you mean smoothed Vusb ? i put a capacitor with 470 nf in the Vusb, is that correct ?
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