Usb Virtual Serial RTOS USB Avr's

92 views
Skip to first unread message

Zac

unread,
Jul 20, 2010, 6:53:29 PM7/20/10
to Micropendous
Heya,

Nice work! Just inquiring have you had any issues running your
USBVirtualSerial Free RTOS build on the USB AVR's? I am trying to run
on a AT90USB1286 and when I upload and connect to PC it throws out a
USB initialization error. I have your standard USBVirtualSerial build
working sweet.

Any help/input appreciated..

Thanks
Zac

Opendous Inc.

unread,
Jul 21, 2010, 10:46:35 AM7/21/10
to Micropendous
Did you set the makefile variables MCU and F_CPU?

Which version of WinAVR or AVR-GCC are you using (run avr-gcc -v)?

Which Micropendous distribution are you using?

I have not encountered a USB initialization error with this firmware
which I tested on AT90USB162, ATmega32U4, AT90USB647, and AT90USB1287
based boards.

Send as much detail as you can and I will try to recreate the problem.

Zac

unread,
Jul 22, 2010, 12:32:20 AM7/22/10
to Micropendous
Hello,

Yes indeedy.

F_CPU = 8000000
MCU = at90usb1286

using WinAVR-20100110
and also using Micropendous-2010-10-11
I am compiling in programmers notepad.

Interesting. I have compilied and mucked around with your
USBVirtualSerial and works fine.
USB boots up initialises, printf's and everything. Good stuff. But for
some reason doesn't initialise with the RTOS?
As to go with the

Thanks for input,
Zac

Opendous Support

unread,
Jul 25, 2010, 5:25:00 PM7/25/10
to microp...@googlegroups.com
Any luck getting your board to work with the FreeRTOS example?

Have you set any fuses?

I have included some compiled versions of the firmware which you can load with:

batchisp -hardware usb -device $(MCU) -operation erase f
batchisp -hardware usb -device $(MCU) -operation loadbuffer
USBVirtualSerial_FreeRTOS_AT90USB1286_8Mhz.hex program

USBVirtualSerial_FreeRTOS_AT90USB1286_8Mhz.hex
USBVirtualSerial_FreeRTOS_AT90USB1286_16MHz.hex
USBVirtualSerial_FreeRTOS_AT90USB1287_16MHz.hex

Opendous Support

unread,
Jul 22, 2010, 4:35:00 PM7/22/10
to Micropendous
I just tested the FreeRTOS examples from the
Micropendous-2009-10-11.zip and Micropendous-2010-03-15.zip
distributions and they work fine for me on an ATmega32U4 with an 8MHz
crystal and an AT90USB1287 with a 16MHz crystal.

Unfortunately I do not have an AT90USB1286 board to test the
firmware on.

Try running 'make clean' before 'make flip' in case there are
some leftover files from previous builds. Also try manually resetting
and/or re-plugging your board after firmware upload.

Double-check your F_CPU and F_CLOCK values are correct.

Zac Halls

unread,
Jul 27, 2010, 6:07:17 PM7/27/10
to microp...@googlegroups.com
Hey,

ahh no luck unfortunately. I havent set any fuses cause just uploading with flip.

I tried your compile as well still comes up with initialization error ahhh...
F_CPU and F_CLOCK values are correct F_CPU = 8000000

Tried re-plugging still issue. Tried in both xp and win 7 machine.
Its strange cause the RTOS works fine when i take out the usb protocol.
Also your standard USBVirtualSerial build works fine and the usb initializes fine :s

Thanks for support though
Zac

Zac Halls

unread,
Jul 28, 2010, 1:00:38 AM7/28/10
to microp...@googlegroups.com
It is completely possible for me to initialize the usb protocol in a timed loop before the execution of the RTOS. And if it doesn't connect there within a certain time i get it to execute the RTOS. I have tried this and it works; well, not being the best way to solve issue it works. haha. i am thinking this has to be an interrupt issue or some sort of timing glitch.

Thanks
Zac

On Fri, Jul 23, 2010 at 6:35 AM, Opendous Support <opendous...@gmail.com> wrote:

Opendous Inc.

unread,
Jul 28, 2010, 12:02:38 PM7/28/10
to Micropendous
Any chance you could describe your circuit?

Are any pins GND'ed or pulled up? There may be some wayward interrupt
that is enabled but not being handled.

Do you have any Ubuntu Live CDs you could test your board with? Linux
dmesg info would be very helpful.

Do you have any other USB AVR boards you could test your firmware+OS
combination?

Have you tried other host ports? Some computers have multiple USB
root ports. It is hard to tell which USB port goes to which root so
try all of them and see if you still get the same results.

On Jul 28, 1:00 am, Zac Halls <zhjha...@gmail.com> wrote:
> It is completely possible for me to initialize the usb protocol in a timed
> loop before the execution of the RTOS. And if it doesn't connect there
> within a certain time i get it to execute the RTOS. I have tried this and it
> works; well, not being the best way to solve issue it works. haha. i am
> thinking this has to be an interrupt issue or some sort of timing glitch.
>
> Thanks
> Zac
>
> On Fri, Jul 23, 2010 at 6:35 AM, Opendous Support <
>

Zac Halls

unread,
Aug 6, 2010, 12:03:56 AM8/6/10
to microp...@googlegroups.com
Hey,

Yea I can describe the circuit. Its basically an inertial sensor measuring device. Accellerometer some gyros, microsd card, nordic L01 2.4ghz chip and a tiny lcd display..  :) I do have some pull ups and gnds prob...

Just some info. i have found a slight way to get around this issue. basically i am going to set it up for 2 modes usb mode and non usb mode where a button will toggle in and out. I can get the usbtask to inititalize properly if I set up the continual loop without the timing inturrupts. like say

static void USBTask(void *pvParameters)
{

    for(;;) {
        USB_Task();

    }
}

But if I introduce any concurrent tasks it will not initialize properly. So through the button press I will add and remove the tasks from the scheduler as desired. So I am thinking. I have tried this on one of my other boards which i had made and has the same issue. I have also tried my other usb host ports. i will have a look into it on my linux machine later.

Cheers,
Zac

Opendous Inc.

unread,
Aug 7, 2010, 2:58:29 PM8/7/10
to Micropendous
Try disabling interrupts before calling USB_Task and re-enable them
afterwards.

Also look into the following discussion:
http://groups.google.com/group/myusb-support-list/browse_thread/thread/74583262d64be764/c776bfb0f8248ca1?lnk=gst&q=freertos#c776bfb0f8248ca1

On Aug 6, 12:03 am, Zac Halls <zhjha...@gmail.com> wrote:
> Hey,
>
> Yea I can describe the circuit. Its basically an inertial sensor measuring
> device. Accellerometer some gyros, microsd card, nordic L01 2.4ghz chip and
> a tiny lcd display.. :) I do have some pull ups and gnds prob...
>
> Just some info. i have found a slight way to get around this issue.
> basically i am going to set it up for 2 modes usb mode and non usb mode
> where a button will toggle in and out. I can get the usbtask to inititalize
> properly if I set up the continual loop without the timing inturrupts. like
> say
>
> static void USBTask(void *pvParameters)
> {
>
> for(;;) {
> USB_Task();
>
> }
>
> }
>
> But if I introduce any concurrent tasks it will not initialize properly. So
> through the button press I will add and remove the tasks from the scheduler
> as desired. So I am thinking. I have tried this on one of my other boards
> which i had made and has the same issue. I have also tried my other usb host
> ports. i will have a look into it on my linux machine later.
>
> Cheers,
> Zac
>

Zac Halls

unread,
Aug 8, 2010, 6:44:03 PM8/8/10
to microp...@googlegroups.com
ahhh nice. Works like charm.

Thanks for support.

Zac

Opendous Support

unread,
Aug 9, 2010, 11:54:11 AM8/9/10
to Micropendous
So your code in main() looks like this:

cli(); // disable interrupts
USB_Task(); // run USB tasks
sei(); // enable interrupts

and now everything works?

Do you have any interrupts enabled other than USB and Timer1? Note
that this solution will delay any other interrupts from being handled
instantly.

On Aug 8, 10:44 pm, Zac Halls <zhjha...@gmail.com> wrote:
> ahhh nice. Works like charm.
>
> Thanks for support.
>
> Zac
>
> On Sun, Aug 8, 2010 at 4:58 AM, Opendous Inc. <opend...@gmail.com> wrote:
> > Try disabling interrupts before calling USB_Task and re-enable them
> > afterwards.
>
> > Also look into the following discussion:
>
> >http://groups.google.com/group/myusb-support-list/browse_thread/threa...

Zac Halls

unread,
Aug 9, 2010, 5:46:31 PM8/9/10
to microp...@googlegroups.com
Hey,

Yes exactly.

void USB_Task(void)
{
    /* Read bytes from the USB OUT endpoint into the local buffer */
    for (uint8_t DataBytesRem = CDC_Device_BytesReceived(&VirtualSerial_CDC_Interface); DataBytesRem != 0; DataBytesRem--)
    {
        if (!(BUFF_STATICSIZE - Host_to_Device_Buffer.Elements))
            break;
        Buffer_StoreElement(&Host_to_Device_Buffer, CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface));
    }

    /* Read bytes from the data buffer into the USB IN endpoint */
    while (Device_to_Host_Buffer.Elements)
        CDC_Device_SendByte(&VirtualSerial_CDC_Interface, Buffer_GetElement(&Device_to_Host_Buffer));

    CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
    cli();
    USB_USBTask();
   
sei();
}

No other interrupts as to yet. Yea I thought there may be some sort of delay. For now will still be ok.

Zac
Reply all
Reply to author
Forward
0 new messages