<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forums.obdev.at/app.php/feed/topic/1627" />

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2008-08-26T18:23:52+02:00</updated>

	<author><name><![CDATA[Objective Development Forums]]></name></author>
	<id>https://forums.obdev.at/app.php/feed/topic/1627</id>

		<entry>
		<author><name><![CDATA[christian]]></name></author>
		<updated>2008-08-26T18:23:52+02:00</updated>

		<published>2008-08-26T18:23:52+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=1627&amp;p=6069#p6069</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=1627&amp;p=6069#p6069"/>
		<title type="html"><![CDATA[Atmega8 --&gt; unknown device?!?]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=1627&amp;p=6069#p6069"><![CDATA[
Please try with the firmware and fuse values of a project which is known to work. You will very likely find a project which uses the same pins for D+ and D- and which is based on the ATMega8. This way you can prove that your hardware is OK. Then start playing around with the firmware.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=8">christian</a> — Tue Aug 26, 2008 6:23 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2008-08-06T14:59:28+02:00</updated>

		<published>2008-08-06T14:59:28+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=1627&amp;p=5947#p5947</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=1627&amp;p=5947#p5947"/>
		<title type="html"><![CDATA[Atmega8 --&gt; unknown device?!?]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=1627&amp;p=5947#p5947"><![CDATA[
Hallo,<br /><br />Everytime if I connect my Atmega8 to the PC, there is popping up a message that the device is unknown (Vendor an Product-ID is 0).<br /><br />So I have a few questions:<br /><br />1. How do I have to set my Fusebits?<br />2. Is it possible that the EEPROM-Data is empty?<br />3. Is there any mistake in the syntax of the program?<br /><br />I have a 16MHz Quartz for Clock and the 3V6-Z-Diodes version (like it is in the example circuit). But the Voltages at D+ and D- are correct!<br /><br /><br />Here is my USBCONFIG.h<br /><div class="codebox"><p>Code: </p><pre><code>/* Name: usbconfig.h<br /> * Project: AVR USB driver<br /> * Author: Christian Starkjohann<br /> * Creation Date: 2005-04-01<br /> * Tabsize: 4<br /> * Copyright: &#40;c&#41; 2005 by OBJECTIVE DEVELOPMENT Software GmbH<br /> * License: GNU GPL v2 &#40;see License.txt&#41; or proprietary &#40;CommercialLicense.txt&#41;<br /> * This Revision: $Id: usbconfig-prototype.h 600 2008-05-13 10:34:56Z cs $<br /> */<br /><br />#ifndef __usbconfig_h_included__<br />#define __usbconfig_h_included__<br /><br />/*<br />General Description:<br />This file is an example configuration &#40;with inline documentation&#41; for the USB<br />driver. It configures AVR-USB for USB D+ connected to Port D bit 2 &#40;which is<br />also hardware interrupt 0 on many devices&#41; and USB D- to Port D bit 4. You may<br />wire the lines to any other port, as long as D+ is also wired to INT0 &#40;or any<br />other hardware interrupt, as long as it is the highest level interrupt, see<br />section at the end of this file&#41;.<br />+ To create your own usbconfig.h file, copy this file to your project's<br />+ firmware source directory&#41; and rename it to &quot;usbconfig.h&quot;.<br />+ Then edit it accordingly.<br />*/<br /><br />/* ---------------------------- Hardware Config ---------------------------- */<br /><br />#define USB_CFG_IOPORTNAME      D<br />/* This is the port where the USB bus is connected. When you configure it to<br /> * &quot;B&quot;, the registers PORTB, PINB and DDRB will be used.<br /> */<br />#define USB_CFG_DMINUS_BIT      4<br />/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.<br /> * This may be any bit in the port.<br /> */<br />#define USB_CFG_DPLUS_BIT       2<br />/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.<br /> * This may be any bit in the port. Please note that D+ must also be connected<br /> * to interrupt pin INT0! &#91;You can also use other interrupts, see section<br /> * &quot;Optional MCU Description&quot; below, or you can connect D- to the interrupt, as<br /> * it is required if you use the USB_COUNT_SOF feature. If you use D- for the<br /> * interrupt, the USB interrupt will also be triggered at Start-Of-Frame<br /> * markers every millisecond.&#93;<br /> */<br />#define USB_CFG_CLOCK_KHZ       &#40;16000&#41;<br />/* Clock rate of the AVR in MHz. Legal values are 12000, 15000, 16000, 16500<br /> * and 20000. The 16.5 MHz version of the code requires no crystal, it<br /> * tolerates +/- 1% deviation from the nominal frequency. All other rates<br /> * require a precision of 2000 ppm and thus a crystal!<br /> * Default if not specified: 12 MHz<br /> */<br /><br />/* ----------------------- Optional Hardware Config ------------------------ */<br /><br />/* #define USB_CFG_PULLUP_IOPORTNAME   D */<br />/* If you connect the 1.5k pullup resistor from D- to a port pin instead of<br /> * V+, you can connect and disconnect the device from firmware by calling<br /> * the macros usbDeviceConnect&#40;&#41; and usbDeviceDisconnect&#40;&#41; &#40;see usbdrv.h&#41;.<br /> * This constant defines the port on which the pullup resistor is connected.<br /> */<br />/* #define USB_CFG_PULLUP_BIT          4 */<br />/* This constant defines the bit number in USB_CFG_PULLUP_IOPORT &#40;defined<br /> * above&#41; where the 1.5k pullup resistor is connected. See description<br /> * above for details.<br /> */<br /><br />/* --------------------------- Functional Range ---------------------------- */<br /><br />#define USB_CFG_HAVE_INTRIN_ENDPOINT    0<br />/* Define this to 1 if you want to compile a version with two endpoints: The<br /> * default control endpoint 0 and an interrupt-in endpoint &#40;any other endpoint<br /> * number&#41;.<br /> */<br />#define USB_CFG_HAVE_INTRIN_ENDPOINT3   0<br />/* Define this to 1 if you want to compile a version with three endpoints: The<br /> * default control endpoint 0, an interrupt-in endpoint 3 &#40;or the number<br /> * configured below&#41; and a catch-all default interrupt-in endpoint as above.<br /> * You must also define USB_CFG_HAVE_INTRIN_ENDPOINT to 1 for this feature.<br /> */<br />#define USB_CFG_EP3_NUMBER              3<br />/* If the so-called endpoint 3 is used, it can now be configured to any other<br /> * endpoint number &#40;except 0&#41; with this macro. Default if undefined is 3.<br /> */<br />/* #define USB_INITIAL_DATATOKEN           USBPID_DATA1 */<br />/* The above macro defines the startup condition for data toggling on the<br /> * interrupt/bulk endpoints 1 and 3. Defaults to USBPID_DATA1.<br /> * Since the token is toggled BEFORE sending any data, the first packet is<br /> * sent with the oposite value of this configuration!<br /> */<br />#define USB_CFG_IMPLEMENT_HALT          0<br />/* Define this to 1 if you also want to implement the ENDPOINT_HALT feature<br /> * for endpoint 1 &#40;interrupt endpoint&#41;. Although you may not need this feature,<br /> * it is required by the standard. We have made it a config option because it<br /> * bloats the code considerably.<br /> */<br />#define USB_CFG_INTR_POLL_INTERVAL      10<br />/* If you compile a version with endpoint 1 &#40;interrupt-in&#41;, this is the poll<br /> * interval. The value is in milliseconds and must not be less than 10 ms for<br /> * low speed devices.<br /> */<br />#define USB_CFG_IS_SELF_POWERED         0<br />/* Define this to 1 if the device has its own power supply. Set it to 0 if the<br /> * device is powered from the USB bus.<br /> */<br />#define USB_CFG_MAX_BUS_POWER           100<br />/* Set this variable to the maximum USB bus power consumption of your device.<br /> * The value is in milliamperes. &#91;It will be divided by two since USB<br /> * communicates power requirements in units of 2 mA.&#93;<br /> */<br />#define USB_CFG_IMPLEMENT_FN_WRITE      1<br />/* Set this to 1 if you want usbFunctionWrite&#40;&#41; to be called for control-out<br /> * transfers. Set it to 0 if you don't need it and want to save a couple of<br /> * bytes.<br /> */<br />#define USB_CFG_IMPLEMENT_FN_READ       0<br />/* Set this to 1 if you need to send control replies which are generated<br /> * &quot;on the fly&quot; when usbFunctionRead&#40;&#41; is called. If you only want to send<br /> * data from a static buffer, set it to 0 and return the data from<br /> * usbFunctionSetup&#40;&#41;. This saves a couple of bytes.<br /> */<br />#define USB_CFG_IMPLEMENT_FN_WRITEOUT   0<br />/* Define this to 1 if you want to use interrupt-out &#40;or bulk out&#41; endpoints.<br /> * You must implement the function usbFunctionWriteOut&#40;&#41; which receives all<br /> * interrupt/bulk data sent to any endpoint other than 0. The endpoint number<br /> * can be found in 'usbRxToken'.<br /> */<br />#define USB_CFG_HAVE_FLOWCONTROL        0<br />/* Define this to 1 if you want flowcontrol over USB data. See the definition<br /> * of the macros usbDisableAllRequests&#40;&#41; and usbEnableAllRequests&#40;&#41; in<br /> * usbdrv.h.<br /> */<br />#define USB_CFG_LONG_TRANSFERS          0<br />/* Define this to 1 if you want to send/receive blocks of more than 254 bytes<br /> * in a single control-in or control-out transfer. Note that the capability<br /> * for long transfers increases the driver size.<br /> */<br />/* #define USB_RX_USER_HOOK&#40;data, len&#41;     if&#40;usbRxToken == &#40;uchar&#41;USBPID_SETUP&#41; blinkLED&#40;&#41;; */<br />/* This macro is a hook if you want to do unconventional things. If it is<br /> * defined, it's inserted at the beginning of received message processing.<br /> * If you eat the received message and don't want default processing to<br /> * proceed, do a return after doing your things. One possible application<br /> * &#40;besides debugging&#41; is to flash a status LED on each packet.<br /> */<br />/* #define USB_RESET_HOOK&#40;resetStarts&#41;     if&#40;!resetStarts&#41;&#123;hadUsbReset&#40;&#41;;&#125; */<br />/* This macro is a hook if you need to know when an USB RESET occurs. It has<br /> * one parameter which distinguishes between the start of RESET state and its<br /> * end.<br /> */<br />/* #define USB_SET_ADDRESS_HOOK&#40;&#41;              hadAddressAssigned&#40;&#41;; */<br />/* This macro &#40;if defined&#41; is executed when a USB SET_ADDRESS request was<br /> * received.<br /> */<br />#define USB_COUNT_SOF                   0<br />/* define this macro to 1 if you need the global variable &quot;usbSofCount&quot; which<br /> * counts SOF packets. This feature requires that the hardware interrupt is<br /> * connected to D- instead of D+.<br /> */<br />#define USB_CFG_HAVE_MEASURE_FRAME_LENGTH   0<br />/* define this macro to 1 if you want the function usbMeasureFrameLength&#40;&#41;<br /> * compiled in. This function can be used to calibrate the AVR's RC oscillator.<br /> */<br /><br />/* -------------------------- Device Description --------------------------- */<br /><br />#define  USB_CFG_VENDOR_ID       0xc0, 0x16<br />/* USB vendor ID for the device, low byte first. If you have registered your<br /> * own Vendor ID, define it here. Otherwise you use one of obdev's free shared<br /> * VID/PID pairs. Be sure to read USBID-License.txt for rules!<br /> * + This template uses obdev's shared VID/PID pair: 0x16c0/0x5dc.<br /> * + Use this VID/PID pair ONLY if you understand the implications!<br /> */<br />#define  USB_CFG_DEVICE_ID       0xdc, 0x05<br />/* This is the ID of the product, low byte first. It is interpreted in the<br /> * scope of the vendor ID. If you have registered your own VID with usb.org<br /> * or if you have licensed a PID from somebody else, define it here. Otherwise<br /> * you use obdev's free shared VID/PID pair. Be sure to read the rules in<br /> * USBID-License.txt!<br /> * + This template uses obdev's shared VID/PID pair: 0x16c0/0x5dc.<br /> * + Use this VID/PID pair ONLY if you understand the implications!<br /> */<br />#define USB_CFG_DEVICE_VERSION  0x00, 0x01<br />/* Version number of the device: Minor number first, then major number.<br /> */<br />#define USB_CFG_VENDOR_NAME     'o', 'b', 'd', 'e', 'v', '.', 'a', 't'<br />#define USB_CFG_VENDOR_NAME_LEN 8<br />/* These two values define the vendor name returned by the USB device. The name<br /> * must be given as a list of characters under single quotes. The characters<br /> * are interpreted as Unicode &#40;UTF-16&#41; entities.<br /> * If you don't want a vendor name string, undefine these macros.<br /> * ALWAYS define a vendor name containing your Internet domain name if you use<br /> * obdev's free shared VID/PID pair. See the file USBID-License.txt for<br /> * details.<br /> */<br />#define USB_CFG_DEVICE_NAME     'T', 'e', 'm', 'p', 'l', 'a', 't', 'e'<br />#define USB_CFG_DEVICE_NAME_LEN 8<br />/* Same as above for the device name. If you don't want a device name, undefine<br /> * the macros. See the file USBID-License.txt before you assign a name if you<br /> * use a shared VID/PID.<br /> */<br />/*#define USB_CFG_SERIAL_NUMBER   'N', 'o', 'n', 'e' */<br />/*#define USB_CFG_SERIAL_NUMBER_LEN   0 */<br />/* Same as above for the serial number. If you don't want a serial number,<br /> * undefine the macros.<br /> * It may be useful to provide the serial number through other means than at<br /> * compile time. See the section about descriptor properties below for how<br /> * to fine tune control over USB descriptors such as the string descriptor<br /> * for the serial number.<br /> */<br />#define USB_CFG_DEVICE_CLASS        0xff    /* set to 0 if deferred to interface */<br />#define USB_CFG_DEVICE_SUBCLASS     0<br />/* See USB specification if you want to conform to an existing device class.<br /> * Class 0xff is &quot;vendor specific&quot;.<br /> */<br />#define USB_CFG_INTERFACE_CLASS     0   /* define class here if not at device level */<br />#define USB_CFG_INTERFACE_SUBCLASS  0<br />#define USB_CFG_INTERFACE_PROTOCOL  0<br />/* See USB specification if you want to conform to an existing device class or<br /> * protocol. The following classes must be set at interface level:<br /> * HID class is 3, no subclass and protocol required &#40;but may be useful!&#41;<br /> * CDC class is 2, use subclass 2 and protocol 1 for ACM<br /> */<br /> #define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH    0<br />/* Define this to the length of the HID report descriptor, if you implement<br /> * an HID device. Otherwise don't define it or define it to 0.<br /> * If you use this define, you must add a PROGMEM character array named<br /> * &quot;usbHidReportDescriptor&quot; to your code which contains the report descriptor.<br /> * Don't forget to keep the array and this define in sync!<br /> */<br /><br />/* #define USB_PUBLIC static */<br />/* Use the define above if you #include usbdrv.c instead of linking against it.<br /> * This technique saves a couple of bytes in flash memory.<br /> */<br /><br />/* ------------------- Fine Control over USB Descriptors ------------------- */<br />/* If you don't want to use the driver's default USB descriptors, you can<br /> * provide our own. These can be provided as &#40;1&#41; fixed length static data in<br /> * flash memory, &#40;2&#41; fixed length static data in RAM or &#40;3&#41; dynamically at<br /> * runtime in the function usbFunctionDescriptor&#40;&#41;. See usbdrv.h for more<br /> * information about this function.<br /> * Descriptor handling is configured through the descriptor's properties. If<br /> * no properties are defined or if they are 0, the default descriptor is used.<br /> * Possible properties are:<br /> *   + USB_PROP_IS_DYNAMIC: The data for the descriptor should be fetched<br /> *     at runtime via usbFunctionDescriptor&#40;&#41;.<br /> *   + USB_PROP_IS_RAM: The data returned by usbFunctionDescriptor&#40;&#41; or found<br /> *     in static memory is in RAM, not in flash memory.<br /> *   + USB_PROP_LENGTH&#40;len&#41;: If the data is in static memory &#40;RAM or flash&#41;,<br /> *     the driver must know the descriptor's length. The descriptor itself is<br /> *     found at the address of a well known identifier &#40;see below&#41;.<br /> * List of static descriptor names &#40;must be declared PROGMEM if in flash&#41;:<br /> *   char usbDescriptorDevice&#91;&#93;;<br /> *   char usbDescriptorConfiguration&#91;&#93;;<br /> *   char usbDescriptorHidReport&#91;&#93;;<br /> *   char usbDescriptorString0&#91;&#93;;<br /> *   int usbDescriptorStringVendor&#91;&#93;;<br /> *   int usbDescriptorStringDevice&#91;&#93;;<br /> *   int usbDescriptorStringSerialNumber&#91;&#93;;<br /> * Other descriptors can't be provided statically, they must be provided<br /> * dynamically at runtime.<br /> *<br /> * Descriptor properties are or-ed or added together, e.g.:<br /> * #define USB_CFG_DESCR_PROPS_DEVICE   &#40;USB_PROP_IS_RAM | USB_PROP_LENGTH&#40;18&#41;&#41;<br /> *<br /> * The following descriptors are defined:<br /> *   USB_CFG_DESCR_PROPS_DEVICE<br /> *   USB_CFG_DESCR_PROPS_CONFIGURATION<br /> *   USB_CFG_DESCR_PROPS_STRINGS<br /> *   USB_CFG_DESCR_PROPS_STRING_0<br /> *   USB_CFG_DESCR_PROPS_STRING_VENDOR<br /> *   USB_CFG_DESCR_PROPS_STRING_PRODUCT<br /> *   USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER<br /> *   USB_CFG_DESCR_PROPS_HID<br /> *   USB_CFG_DESCR_PROPS_HID_REPORT<br /> *   USB_CFG_DESCR_PROPS_UNKNOWN &#40;for all descriptors not handled by the driver&#41;<br /> *<br /> */<br /><br />#define USB_CFG_DESCR_PROPS_DEVICE                  0<br />#define USB_CFG_DESCR_PROPS_CONFIGURATION           0<br />#define USB_CFG_DESCR_PROPS_STRINGS                 0<br />#define USB_CFG_DESCR_PROPS_STRING_0                0<br />#define USB_CFG_DESCR_PROPS_STRING_VENDOR           0<br />#define USB_CFG_DESCR_PROPS_STRING_PRODUCT          0<br />#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER    0<br />#define USB_CFG_DESCR_PROPS_HID                     0<br />#define USB_CFG_DESCR_PROPS_HID_REPORT              0<br />#define USB_CFG_DESCR_PROPS_UNKNOWN                 0<br /><br />/* ----------------------- Optional MCU Description ------------------------ */<br /><br />/* The following configurations have working defaults in usbdrv.h. You<br /> * usually don't need to set them explicitly. Only if you want to run<br /> * the driver on a device which is not yet supported or with a compiler<br /> * which is not fully supported &#40;such as IAR C&#41; or if you use a differnt<br /> * interrupt than INT0, you may have to define some of these.<br /> */<br />/* #define USB_INTR_CFG            MCUCR */<br />/* #define USB_INTR_CFG_SET        &#40;&#40;1 &lt;&lt; ISC00&#41; | &#40;1 &lt;&lt; ISC01&#41;&#41; */<br />/* #define USB_INTR_CFG_CLR        0 */<br />/* #define USB_INTR_ENABLE         GIMSK */<br />/* #define USB_INTR_ENABLE_BIT     INT0 */<br />/* #define USB_INTR_PENDING        GIFR */<br />/* #define USB_INTR_PENDING_BIT    INTF0 */<br />/* #define USB_INTR_VECTOR         SIG_INTERRUPT0 */<br /><br />#endif /* __usbconfig_h_included__ */<br /></code></pre></div><br /><br /><br />and that's my main routine:<br /><div class="codebox"><p>Code: </p><pre><code>#include &lt;avr/io.h&gt;<br />#include &lt;avr/interrupt.h&gt;<br />#include &lt;stdio.h&gt;<br />#include &lt;string.h&gt;<br />#include &lt;stdlib.h&gt;<br />#include &lt;avr/pgmspace.h&gt;<br />#include &lt;avr/eeprom.h&gt;<br />#include &lt;util/delay.h&gt;<br />#include &lt;avr/wdt.h&gt;<br /><br />#include &quot;usbdrv.h&quot;<br /><br /><br />static uint8_t replyBuf&#91;8&#93;;<br /><br /><br />void avrlab_init&#40;void&#41;<br />&#123;<br />  uint8_t i,j;<br />  <br />  j = 0;<br />  while&#40;--j&#41;&#123;          /* USB Reset by device only required on Watchdog Reset */<br />      i = 0;<br />      while&#40;--i&#41;;      /* delay &gt;10ms for USB reset */<br />  &#125;<br /><br />  usbInit&#40;&#41;;<br />  sei&#40;&#41;;<br />&#125;<br /><br /><br />uint8_t usbFunctionSetup&#40;uint8_t data&#91;8&#93;&#41;<br />&#123;<br />  uchar len = 0;<br />  <br />  <br />  usbMsgPtr = replyBuf;<br />  return len;<br />&#125;<br /><br />uint8_t usbFunctionRead&#40; uint8_t *data, uint8_t len &#41;<br />&#123;<br />  return 0xff;<br />&#125;<br /><br />uint8_t usbFunctionWrite&#40; uint8_t *data, uint8_t len &#41;<br />&#123;<br />  return 0xff;<br />&#125;<br /><br />int main&#40;&#41;<br />&#123;<br /><br />  DDRC = 0;<br /><br />  avrlab_init&#40;&#41;;<br /><br />  for &#40;int i = 0; i &lt;= 7; i++&#41;<br />  &#123;<br />    replyBuf&#91;i&#93; = 0;<br />  &#125;<br /><br /><br />  while &#40;1&#41;<br />    &#123;<br /><br />    replyBuf&#91;1&#93; = PORTC;  <br /><br />  <br />      usbPoll&#40;&#41;; <br />  &#125;<br /><br /><br /><br />  return 1;<br />&#125;<br /></code></pre></div> <br /><br /><br />I hope you can help me!<p>Statistics: Posted by Guest — Wed Aug 06, 2008 2:59 pm</p><hr />
]]></content>
	</entry>
	</feed>
