0

I am trying to configure an AVR32(UC3B0512) microcontroller so that it can appear as a Virtual COM Port to the PC. I followed the instructions in this application note, but could not get it working. I get the error : Unknown USB Device (Device Descriptor Request Failed), when I connect it to the PC.

Source Code :

main.c

#include <asf.h>

int main (void)
{
    sysclk_init();
    irq_initialize_vectors();
    cpu_irq_enable();
    board_init();

    udc_start();

    delay_init(sysclk_get_cpu_hz());

    AVR32_GPIO.port[1].gpers = 0b111;
    AVR32_GPIO.port[1].oders = 0b111;

    while (1)
    {
        AVR32_GPIO.port[1].ovr = 0b111;
        delay_ms(250);

        AVR32_GPIO.port[1].ovr = 0b000;
        delay_ms(250);
    }

    return 0;
}

conf_usb.h

#ifndef _CONF_USB_H_
#define _CONF_USB_H_

#include "compiler.h"

#define  USB_DEVICE_VENDOR_ID             USB_VID_ATMEL
#define  USB_DEVICE_PRODUCT_ID            USB_PID_ATMEL_ASF_CDC
#define  USB_DEVICE_MAJOR_VERSION         1
#define  USB_DEVICE_MINOR_VERSION         0
#define  USB_DEVICE_POWER                 100 // Consumption on Vbus line (mA)
#define  USB_DEVICE_ATTR                  (USB_CONFIG_ATTR_BUS_POWERED)

#define  USB_DEVICE_MANUFACTURE_NAME      "ATMEL"
#define  USB_DEVICE_PRODUCT_NAME          "UC3B0512"
#define  USB_DEVICE_SERIAL_NAME           "12...EF"

#define USB_DEVICE_LOW_SPEED

//! Number of communication port used (1 to 3)
#define  UDI_CDC_PORT_NB 1

//! Interface callback definition
#define  UDI_CDC_ENABLE_EXT(port)          true
#define  UDI_CDC_DISABLE_EXT(port)
#define  UDI_CDC_RX_NOTIFY(port)
#define  UDI_CDC_TX_EMPTY_NOTIFY(port)
#define  UDI_CDC_SET_CODING_EXT(port,cfg)
#define  UDI_CDC_SET_DTR_EXT(port,set)
#define  UDI_CDC_SET_RTS_EXT(port,set)

//! Define it when the transfer CDC Device to Host is a low rate (<512000 bauds)
//! to reduce CDC buffers size
#define  UDI_CDC_LOW_RATE

//! Default configuration of communication port
#define  UDI_CDC_DEFAULT_RATE             115200
#define  UDI_CDC_DEFAULT_STOPBITS         CDC_STOP_BITS_1
#define  UDI_CDC_DEFAULT_PARITY           CDC_PAR_NONE
#define  UDI_CDC_DEFAULT_DATABITS         8

//! The includes of classes and other headers must be done at the end of this file to avoid compile error
#include "udi_cdc_conf.h"

#endif // _CONF_USB_H_

conf_clock.h

#ifndef CONF_CLOCK_H_INCLUDED
#define CONF_CLOCK_H_INCLUDED

#define CONFIG_SYSCLK_SOURCE        SYSCLK_SRC_OSC0

/* Fbus = Fsys / (2 ^ BUS_div) */
#define CONFIG_SYSCLK_CPU_DIV         0
#define CONFIG_SYSCLK_PBA_DIV         0
#define CONFIG_SYSCLK_PBB_DIV         0

#define CONFIG_USBCLK_SOURCE          USBCLK_SRC_PLL1

/* Fusb = Fsys / USB_div */
#define CONFIG_USBCLK_DIV             1 /* Fusb = Fsys/(2 ^ USB_div) */

#define   CONFIG_PLL1_SOURCE          PLL_SRC_OSC0

/* Fpll1 = (Fclk * PLL_mul) / PLL_div */
#define CONFIG_PLL1_MUL               (48000000UL / BOARD_OSC0_HZ)
#define CONFIG_PLL1_DIV               2

#endif /* CONF_CLOCK_H_INCLUDED */

conf_board.h

#ifndef CONF_BOARD_H
#define CONF_BOARD_H

#define BOARD_OSC0_HZ 12000000UL
#define BOARD_OSC0_STARTUP_US OSC_STARTUP_4096
#define BOARD_OSC0_IS_XTAL true

#endif // CONF_BOARD_H
fholly
  • 31
  • 3

1 Answers1

2

I found a solution. It turns out the CDC cannot be used when the USB is configured to low speed support. So I just had to remove the following line from conf_usb.h.

#define USB_DEVICE_LOW_SPEED
fholly
  • 31
  • 3