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

usb_cdc_getc() returns 0 on PIC18F2450

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







usb_cdc_getc() returns 0 on PIC18F2450
PostPosted: Wed Jan 07, 2009 11:45 pm     Reply with quote

HELP!!!

I am trying to get the USB port working on my PIC 18F2450. My code (posted Below) enumerates and the PC side seems happy.

I've written a VB2008 exe that sends one character to the virtual comm port then waits for one character to be returned.

My Pic code receives the one character and sends it right back out.

For some reason, the usb_cdc_getc() funciton seems to only return 0. The transmission from the PIC seems to work. I can hard code it to send integers from 0 to 255 and my VB code reads it okay.

Any thoughts from the community?

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;


void main(){

LED_OFF(led1);
LED_OFF(led2);

usb_init();

while (true) {

if (usb_enumerated()){
led_on(led1);
if(usb_cdc_kbhit()){

DATA_RX = usb_cdc_getc();
usb_cdc_putc(DATA_RX);

}
}
}
enable_interrupts(GLOBAL);
}
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Jan 08, 2009 12:14 am     Reply with quote

usb_task() is missing - at least in the shown code. You can use a software USB monitor and check, if the intended data bytes are actually transmitted to the device.
Gendrick



Joined: 11 Feb 2008
Posts: 8
Location: MATURIN, VENEZUELA

View user's profile Send private message AIM Address Yahoo Messenger ICQ Number

VB code
PostPosted: Sat Jan 10, 2009 11:54 am     Reply with quote

Hi capnmatt, where can I find a VB code for USB port with PIC, thanks , my email is [email protected]
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