Contains Factory Test Routines.
- Copyright
- Copyright (C) 2009 Robert Loos http://www.loosweb.de
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Performs a simple Factory Test.
This routine tries to test everything that can be tested without user intervention. It cannot detect all possible error conditions but will detect a lot of possible short circuits and other errors and can give valuable hints to the test personal.
This is done by performing a "Walking Zero" and a "Walking One" test i.e. all pins are set to 1 (or 0) and a single 0 (or 1) walks through all pins. As long only the currently tested pin is 0, everything is o.k., if another pin goes to 0, you have a short between these two pins. If a pin always stays at a fixed level, you have a short to VCC or GND.
A test mask defines which pins have to be tested. Bits set to 0 will not be touched and not be tested. Bits set to 1 will be programmed as output and tested against all other 1-pins and the supply.
A few rules have to be obeyed for the factory test to work:
-
All special function pins must be set to normal port I/O. Disable all timer outputs, SPIs, USARTS etc. except the interface to the host.
-
Some devices have a DIDR (digital input disable). Do not forget to enable digital inputs.
-
The host interface pins must be set to 0 and cannot be tested. But they are o.k. if the device is able to communicate with the host, anyway.
-
Lines with Chip Select functions should be left as output with Chip Select set to inactive but set to 0 in the test mask. So these pins will not be touched and the chips remain disabled throughout the test and do not interfere with the test sequence.
-
All lines to other chips that are disabled can be set to 1 if the connected chip leaves it tri state when disabled, even if they are input lines normally.
Since interrupts are disabled in the progress of this function and DDRs are modified, the calling routine should perform a watchdog reset to restart the device.
Do not try to restore previous state and continue normal operation, you will most likely forget something and there is nothing bad in willingly performing a reset...
- Returns
- True if no error detected, False if test fails