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 CDC / PIC18LF2550

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



Joined: 12 Dec 2005
Posts: 50
Location: Curitiba - Brazil

View user's profile Send private message Send e-mail

USB CDC / PIC18LF2550
PostPosted: Thu Nov 27, 2008 8:19 am     Reply with quote

PIC18LF2550 - MPLAB 8.10 CCS4.082

Hi, I can exchange data with the computer (hyperterminal) as CDC device but suddenly PIC stops working. It is powered but it seams to crash. I think the connection with computer is lost. The crystal I am using is 20MHz, 3.3V (power from USB + 3.3V regulator) and serial UART at 4800bps.
Also, when I type something ('1','2','3' or '4') the usb crashes.
It is as simple as an USB<-->UART @ 4800bps. What I am doing wrong ?
Thanks in advance, Luiz

My code is:
Code:
#define __USB_PIC_PERIF__ 1

#include <18F2550.h>
#device *=16
#device ADC=10
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,CPUDIV1,VREGEN,PLL5
#use delay(clock=48000000)
#use rs232(baud=4800,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=GPS)
#case

#include <usb_cdc.h>
#include <STDLIB.H>

#define PIN_LED                                  PIN_A0
#define LED_ON()                     output_low(PIN_LED)
#define LED_OFF()                   output_high(PIN_LED)
#define EN_GPS()                     output_high(PIN_A1)
#define DIS_GPS()                    output_low(PIN_A1)
#define OK  1
#define NOK 0

char carac_rs232=0;
char carac_usb;

void main(void)
{           
            usb_init();
            while(!usb_cdc_connected());
            EN_GPS();
       
            printf(usb_cdc_putc,"Usb READY\n\r");
            while(1)
            {
                        if(usb_cdc_kbhit())
                        {
                                   carac_usb = usb_cdc_getc();
                                   //usb_cdc_putc(carac_usb);
                                   switch(carac_usb)
                                   {           case '1':
                                                           fputs("$PTYCRMC,1\015\012",GPS);
                                                           break;
                                               case '2':
                                                           fputs("$PTYCRMC,0\015\012",GPS);
                                                           break;
                                               case '3':
                                                           fputs("$PTYCGGA,1\015\012",GPS);
                                                           break;
                                               case '4':
                                                           fputs("$PTYCGGA,0\015\012",GPS);
                                                           break;
                                   }
                        }
                        if(kbhit(GPS))
                        {          LED_ON();
                                   carac_rs232 = getc(GPS);
                                   usb_cdc_putc(carac_rs232);
                                   LED_OFF();
                        }           
            }// End While
}// End Main
Ttelmah
Guest







PostPosted: Thu Nov 27, 2008 10:02 am     Reply with quote

What capacitors have you go on the USB regulator pin?. What capacitors on the PIC supply itself?. How are you powering the RS232 transceiver?.

Best Wishes
Ttelmah
Guest







PostPosted: Thu Nov 27, 2008 10:41 am     Reply with quote

Whoa.
Re-reading your post, you are running the PIC off 3.3v, with an external 3.3v regulator?. First, you are running too fast for this. The maximum spcified frequency for 3.3v operation, is just 18.6MHz. You need 4.2v, for 48MHz operation. I'd suggest you connect the PIC directly to the USB supply. The PIC also requires that it's supply is always _greater_ than the Vusb supply (even when using an external regulator). You also have Vregen set, which enables the internal 3.3v regulator. To run with an external regulator, requires 'NOVREGEN' The internal regulator (obviously), cannot deliver 3.3v, when driven from 3.3v.

Best Wishes
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