Programatically reset device with C

Discussion about writing software for VS1005 and the VSOS Operating System. Also posts about VS1005-related hardware design and device drivers should be posted here.
Post Reply
RLee
Senior User
Posts: 30
Joined: Wed 2017-11-22 13:43

Programatically reset device with C

Post by RLee »

Hi,

I am going to be deploying a number of recorders for extended periods of time (months) between being checked. I have built in as much reliability in to the PCB design using your guidance, but still remain a little nervous.

Would you know a way to reset the device as part of an error handler that I could incorporate to just ensure that I am still collecting data.

Kind Regards

Rob
Hannu
VLSI Staff
Posts: 559
Joined: Mon 2016-05-30 11:54
Location: Finland
Contact:

Re: Programatically reset device with C

Post by Hannu »

How about watchdog?

You can set the timer quite long with WDOG_CF register and then you need to write the WDOG_KEY register before it expires and if it expires, reset happens.

Code: Select all

void WatchdogReset(void) {
  PERIP(WDOG_CF) = 1;
  PERIP(WDOG_KEY) = 0x4ea9;
  while (1)
    ;
}
RLee
Senior User
Posts: 30
Joined: Wed 2017-11-22 13:43

Re: Programatically reset device with C

Post by RLee »

Watchdog is a new one on me, but looking at it this could be a workaround. for future PCBs I think I will incorporate a transistor so i can pull xreset down, but it's a little late in the day for that.

Thanks very much

Rob
User avatar
pasi
VLSI Staff
Posts: 2174
Joined: Thu 2010-07-15 16:04

Re: Programatically reset device with C

Post by pasi »

Watchdog is the number one way for me to restart the system from scratch in products, e.g. after a firmware update or waking up from standby (when standby has turned off so many things that turning them back on is just unnecessarily duplicated code).

In the case of vs1005 / vs1010 keeping PWRBTN high for 4-5 seconds also causes a reset (unless reset by power-button is disabled).
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook
Hannu
VLSI Staff
Posts: 559
Joined: Mon 2016-05-30 11:54
Location: Finland
Contact:

Re: Programatically reset device with C

Post by Hannu »

VSOS actively disables power button reset in VS1005g. Just for reference, in VS1010 it can be enabled.
RLee
Senior User
Posts: 30
Joined: Wed 2017-11-22 13:43

Re: Programatically reset device with C

Post by RLee »

Thanks for all this information. Watchdog implementation was really easy and seems to have worked really well when deployed
Hannu
VLSI Staff
Posts: 559
Joined: Mon 2016-05-30 11:54
Location: Finland
Contact:

Re: Programatically reset device with C

Post by Hannu »

Nice to hear that the solution worked. And you can use this as watchdog too.

If you start watchdog and enter to while(1); you'll get a reset. On normal cases, you have to feed it before timeout or it bites you. The length of the timeout is something to think about.

However, if you are doing a recorder there is a one nasty thing. Files open to write get finalized on fclose() call. And if fclose() never comes, you'll get file system corruption.
RLee
Senior User
Posts: 30
Joined: Wed 2017-11-22 13:43

Re: Programatically reset device with C

Post by RLee »

That's fine, As the devices are to be deployed for so long I have set it to greater than the length of the file i am recording. If I miss a 10 minute slot here or there it isn't too problematic. Hopefully it will not be needed though.

Thanks

Rob
Post Reply