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 CCS Technical Support

help! cdc example - 18f2450 problem.

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



Joined: 15 Dec 2006
Posts: 109

View user's profile Send private message

help! cdc example - 18f2450 problem.
PostPosted: Wed Dec 24, 2008 2:00 am     Reply with quote

What do I have to modify to make cdc example work in 18F2450 ?
The chip is able to send data but not receiving data.

Example works with 18F2550.
Code:

do {
      usb_task();
      if (usb_enumerated()) {
         printf(usb_cdc_putc, "\r\nHello World !");

         RcvUSB = usb_cdc_getc(); !!!!THIS IS NOT WORKING!!!!

         if (RcvUSB=='b') {
            printf(usb_cdc_putc, "\r\nSee how I blink 20 times on Port A.0 !");
            for (i=1;i<=20;i++) {
               output_bit( PIN_B0, 1);
               delay_ms(250);
               output_bit( PIN_B0, 0);
               delay_ms(250); 
            };
         }
         else
            printf(usb_cdc_putc, "\r\nI just received : %c",RcvUSB);
         
      }
   } while (TRUE);
}

Thanks and regards,
Jai.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Dec 24, 2008 2:49 am     Reply with quote

Did you also examine the CCS provided CDC examples? Generally, they use a construct like this:
Code:
if (usb_cdc_kbhit()) {
  c=usb_cdc_getc();
//....
}

If you call usb_cdc_getc() without a character available, the program will wait for a character, pausing service of the USB interface. This may cause the host to suspend the device.

As another point, I experienced a problem with the CCS USB driver, that apparently failed to reenable global interrupts in some situation. I didn't further investigate the issue, but added an additional reenable at the end of the main loop:
Code:
enable_interrupts(GLOBAL);

It can't do any harm, cause global interrupts are enabled at that program level anyway, but effectively removed my problem.

Best regards and Merry Christmas
Frank
capnmattttt
Guest







help! cdc example - 18f2450 problem.
PostPosted: Mon Jan 05, 2009 11:06 pm     Reply with quote

I am having a similar problem with the 18F2450. I can send characters from the PIC, but I don't seem to receive characters.

Here is my code.
Code:
#include <18F2450.h>
#device adc=8

#fuses ECPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL1,CPUDIV4,VREGEN
#use delay(clock=16000000)

#include <usb_cdc.h>

#define led1            pin_c6
#define led2            pin_c7
#define LED_ON          output_high
#define LED_OFF         output_low

int8 DATA_RX[1];
//int8 byte1;

void main(){
   //int8 i;
   LED_OFF(led1);
   LED_OFF(led2);
     
   usb_init();
     
   while (true) {

      if (usb_enumerated()){
         led_on(led1);
         if(usb_cdc_kbhit()){
           
            //for (i=0;i<31;++i){
            DATA_RX[0] = usb_cdc_getc();
               
            LED_ON(led2);
            Delay_ms(200);
            LED_OFF(led2);
            //}
            //for (i=0;i<32;++i){
            usb_cdc_putc(DATA_RX[0]);
            //}
            Delay_ms(200);
            LED_ON(led2);
            Delay_ms(200);
            LED_OFF(led2);
          }
      }
   }
enable_interrupts(GLOBAL);
}
jaikumar



Joined: 15 Dec 2006
Posts: 109

View user's profile Send private message

Give it up. Use the 18F2550.
PostPosted: Thu Jan 08, 2009 2:12 am     Reply with quote

My Advice,

Give it up. Don't waste time. The cdc uses about 65% of RAM and believe me
you need a lot of them.
I wonder even if the 18F2550 is Good enough for a bit large app. This cdc example and all other do work on 18F2550 so Change your chip.
Any way here in india we don't save too much money any way.

Regards,
Jai.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Jan 08, 2009 2:54 am     Reply with quote

You're right, that RAM capacity is critical with PIC2450. I don't have it and can't check, if basic CDC is working there, but I suppose it does. The present code however can't work without an usb_task() call.
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