Hi, all,
I have finally moved on from writing everything in assembler and tried out C, mostly to grasp and fiddle with USB on AVR, with LUFA! Yay!
First, kudoes: It just worked. Unlike the Atmel supplied code, a LUFA demo just worked.
I'm using the DualVirtualSerial, and am wondering if I've done something silly or found a serious problem...
Echoing a character? Worked fine. For grins, I threw in an incrementer (Receivebyte++) line, so if you give it a 'c' you get back a 'd'. Incidentally, I suggest this for all serial port demos, as it keeps out confusion possible through local echo settings.
So I got a little more ambitious, and set up a character array, char Test[50], and initialized it with a little for loop
for (i = 0; i < 50; i++) { Test[i] = i + 0x30; }
This fills the array with ASCII "0123..." through "a". To send it to the USB Serial device, another for loop:
for (i = 10; i < 20; i++ ) { ReceivedByte = Test[i]; CDC_Device_SendByte(&VirtualSerial2_CDC_Interface, (uint8_t)ReceivedByte); } ReceivedByte = 0x0D; CDC_Device_SendByte(&VirtualSerial2_CDC_Interface, (uint8_t)ReceivedByte); }
With a handy carriage return, sending a slice of the array off to the PC.
This works fine.
Now (still with me?) comes the problem.
I want to send a similar slice of the array in reverse order. Replacing only the loop with a decrementing one does NOT work:
for (i = 20; i < 10; i-- ) {
I get no characters at all. The carriage return (outside the for loop) still shows up just fine. But nothing else...
Have I done something silly here? (I'm using WinAVR and Studio 4, programming with avrdude) Am I trampling on a variable somewhere I shouldn't be?
Anyone?
S.