resetting my device

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
ulao
Rank 4
Rank 4
Posts: 481
Joined: Mon Aug 25, 2008 8:45 pm

resetting my device

Post by ulao » Sun Apr 24, 2011 6:38 pm

Normally this works rather well by pulling the reset line low to my avr, however I'm now forced to use pc6 ( my reset line ) and I'm looking for another way to reset my device. I always though pulling the white usb lead low would do it, but that just "pauses" the usb, it does not do a thing to the avr code. Another way is simple pulling +5 low, but is that bright? It works, just seems a bit chancy. Any ideas? I need a one lead solution as my design has a 1 poll switch.

_frank26080115

Re: resetting my device

Post by _frank26080115 » Mon Apr 25, 2011 10:05 pm

how about you detect the pulling, and then use the watchdog timer to perform the reset?

ulao
Rank 4
Rank 4
Posts: 481
Joined: Mon Aug 25, 2008 8:45 pm

Re: resetting my device

Post by ulao » Mon Apr 25, 2011 10:13 pm

could be the answer I'm looking for, thx.

ulao
Rank 4
Rank 4
Posts: 481
Joined: Mon Aug 25, 2008 8:45 pm

Re: resetting my device

Post by ulao » Thu Apr 28, 2011 8:30 pm

Could some one please explain to me why this does not work?


I added the cli/sei and usb dropping in hopes it woudl help.

Code: Select all

cli();
usbDeviceDisconnect();
      DDRD &= ~0x02;_delay_us(.1);
      if (! (PIND & 0x02) ) blinkLed(1);//{   WDTCSR = ((1<<WDCE) | (1<<WDE)); while(1) {} }
      
      DDRD |= 0x02;
usbDeviceConnect();
sei()


I need to be able to detect when the PD1 or PD2 gets pulled low. PD1 has my usb - lead. and PD3 has my usb + lead. PD2 has my pull up operated via usb connect/disconnect. I'm able to watch any other pin on another port. For some reason I can not watch for a low on these pins.

My guess here is that the pulling of lead + is releasing the power to the mcu ( effectively not running the code above ) but the entire reason for this is because the mcu is retaining its last state? So its like the memory in the mcu is intact but its not capable of running the clock.

ulao
Rank 4
Rank 4
Posts: 481
Joined: Mon Aug 25, 2008 8:45 pm

Re: resetting my device

Post by ulao » Thu Apr 28, 2011 11:32 pm

Wow, ok so apparently its in the while (!usbInterruptIsReady()) loop at this time. So I have to run a checkAlive in there to test for a low condition over time.


This does work, but damn its ugly! During this loop I see the usb data on that pin, but if its held low for the entire loop it returns all checks false, resulting in 245. Anyone have a better solution to offer?

Code: Select all

static void checkAlive(void)
{ if (!checkAliveEnabled) return;
   unsigned char i=0;
   DDRD &= ~0x02;
   for( ; i < 254 ; i++)
   {
      if (PIND & 0x02) break;
   }
   DDRD |= 0x02;

   if (i==254)  //do something...

}


I did try

Code: Select all

WDTCSR = ((1<<WDCE) | (1<<WDE)); while(1);
but it didnt work. I did find a working reset option for now.

Post Reply