ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
Hmm getting usb catching commands |
Posted: Wed Sep 19, 2007 9:40 pm |
|
|
Hi,
I know that this subject has been discuted alot of times but seriously i tryed doing something more simpler to simply catch a caracter to execute a (in this case) test command.
Code: |
#include <18F2550.h>
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL3,CPUDIV1,VREGEN
#use delay(clock=48000000)
#include <usb_cdc.h>
#use standard_io(A)
BYTE commandstr[5];
BYTE i;
void main(void) {
usb_cdc_init();
usb_init();
while (TRUE) {
usb_task();
if (usb_cdc_kbhit()) {
for(i=0;i<5;++i){
commandstr[i]=usb_cdc_getc();
}
if (commandstr[0]== '1'){
output_high(PIN_A1);
}
if (commandstr[0]== '0'){
output_low(PIN_A1);
}
}
}
}
|
PuTTY freeze on login (COM4)
Tryed the echo loopback code, worked #1
i'm using the pic18f2550 via USB with a 12MHZ quartz.
PS: commandstr is a 6 caracters array so i can use longer command in the next time
Thank you,
have a nice day |
|