PIC C - USB_CDC_GETC() and retrieving strings.
Posted
by Adam
on Stack Overflow
See other posts from Stack Overflow
or by Adam
Published on 2010-03-31T01:58:40Z
Indexed on
2010/03/31
2:03 UTC
Read the original article
Hit count: 411
Hi all, I'm programming a PIC18F4455 Microcontroller using PIC C. I'm using the USB_CDC.h header file. I have a program on the computer sending a string such as "W250025". However, when I use usb_cdc_getc() to get the first char, it freezes. Sometimes the program sends only 'T', so I really want to just get the first character.
Why does my code never execute past received=usb_cdc_getc(); when I send "W250025"?
if (usb_cdc_kbhit())
{
//printf(lcd_putc, "Check 3"); delay_ms(3000); printf(lcd_putc, "\f");
received = usb_cdc_getc();
printf(lcd_putc, "Received "); lcd_putc(received); delay_ms(3000); printf(lcd_putc, "\f");
if (received == 'W'){ //waveform
disable_interrupts(INT_TIMER1);
set_adc_channel(0);
load_and_print_array(read_into_int(), read_into_int());}
else if (received == 'T'){ //temperature
set_adc_channel(1);
enable_interrupts(INT_TIMER1);}
}
© Stack Overflow or respective owner