|
|
View previous topic :: View next topic |
Author |
Message |
capnmatt Guest
|
usb_cdc_getc() returns 0 on PIC18F2450 |
Posted: Wed Jan 07, 2009 11:45 pm |
|
|
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
|
|
Posted: Thu Jan 08, 2009 12:14 am |
|
|
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
|
VB code |
Posted: Sat Jan 10, 2009 11:54 am |
|
|
Hi capnmatt, where can I find a VB code for USB port with PIC, thanks , my email is [email protected] |
|
|
|
|
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
|