My first question, which I haven't yet been able to figure out, is: PowerSwitch identifies itself as what kind of USB device?
Next, here's my log of trying to set up PowerSwitch on an attiny2313.
Downloaded source files, moved them to C:\ since compiler was complaining. (I'm running AVR Studio in WinXP SP2). Included all files, successfully compiled for attiny2313 at 12 MHz. Started programmer, configured fuses, checked if attiny is bricked. Nope. Breadboarded the schematic: Dropped the regulator, external power supply, added two diodes in series to get the voltage drop, added the 1.5k and 1M resistors, used 50ohm instead of the 68 resistors. Added a single cap of 10uF on the power rails.
The whole thing is now powered via USB, including my programmer (STK200 homemade). Kanda AVRISP (programmer software) sees the device. Burnt the hex into the device, leds light up, "usb device not recognised" pops up, avr is now bricked. Try to unbrick, but nothing works.
I now switched to atmega16.
I changed the following: using PD0 and PD2 for D- and D+ (PD2 has INT0). I also use the whole PORTC for output instead of breaking the incoming data for two ports. Changes:
usbconfig.h
Code: Select all
#define USB_CFG_IOPORTNAME D
#define USB_CFG_DMINUS_BIT 0
#define USB_CFG_DPLUS_BIT 2
main.cpp
Code: Select all
int main(void)
{
uchar i;
wdt_enable(WDTO_1S);
odDebugInit();
DDRD = ~(1 << 2); /* all outputs except PD2 = INT0 */
PORTD = 0;
PORTB = 0; /* no pullups on USB pins */
/* We fake an USB disconnect by pulling D+ and D- to 0 during reset. This is
* necessary if we had a watchdog reset or brownout reset to notify the host
* that it should re-enumerate the device. Otherwise the host's and device's
* concept of the device-ID would be out of sync.
*/
//DDRB = ~USBMASK; /* set all pins as outputs except USB */
DDRD = ~USBMASK;
computeOutputStatus(); /* set output status before we do the delay */
usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */
i = 0;
while(--i){ /* fake USB disconnect for > 500 ms */
wdt_reset();
_delay_ms(2);
}
usbDeviceConnect();
... }
static void outputByte(uchar b)
{
//PORTB = (PORTB & ~0xfc) | (b & 0xfc);
//PORTD = (PORTD & ~0x30) | ((b << 4) & 0x30);]
PORTC = b;
}
No AVR ever enumerated. What should I do?