A while ago I was testing the following SPI function, which basically does 3 things: (1) Create a spi object, (2) open SPI0, CE1_N, (3) write to SPI0 600 times.
But then I found the RPi not responding, and I found the TP1/TP2 drops to below 4V and all on board indictaor LEDs went off.  To troubleshoot, I removed the hardware connected to the RPi, one by one, first SPI hardware, then I2C hardware, then the signal routing hardware, but no luck.  Then I removed ALL the connecting cables from the RPI, but the problem does not go away.  At last I removed the HDMI and Ethernet connectors, but still the RPI only tried to boot for about 30 seconds, then all LEDs off.
I guess part of the RPi is permanently damaged. In other words, it is half dead!
I don't know what was the cause. It is unlikely that the SPI test program kills it, because I have not yet connected any hardware device to it. I only thought to use the scope to display the MOSI wave forms, ...
I think I need to swap another RPi.
I guess part of the RPi is permanently damaged. In other words, it is half dead!
I don't know what was the cause. It is unlikely that the SPI test program kills it, because I have not yet connected any hardware device to it. I only thought to use the scope to display the MOSI wave forms, ...
I think I need to swap another RPi.
def TestWiringPiSpi():
    print "\n" + "*** Start testing wiringPi SPI, ... ***" + "\n"
    spi = spidev.SpiDev() # create spidev object
    spi.open(0,1) # open SPI0, CE1_N
    for i in range(600):  
        TwoByteArray = spi.xfer2([0xf0, 0x0f]) # write and read 2 bytes
    time.sleep(0.01)
    print "\n" + "*** Stop testing wiringPi SPI, ... ***" + "\n"
.END
# *****************************************************************************
# *****************************************************************************
# !/usr/bin/python2.7
#
# Hardware/Software
#   FongLab Fpl4 - 2013feb
# Author
#   tlfong01  
# Configuration
#   Raspberry Pi Bv2 512MB, Raspbian Wheezy, Python 2.7.3, RPI.GPIO 0.4.1a,
#   PythonWiringPi 1.0.5
# License
#   GNU GPLv3
# Warranty 
#   For hobbist only.  Use at your own risk.  There is not any warranty.
# System development methodologies/Programming paradims 
#   Software prototyping, Test-driven (TDD), Iterative and incremental (IID),
#   Agile/Functional Programming (FP), Object Oriented Programming (OOP).
# Specifications summary
#   5V0max 50mA, 3V3max 300mA, PerPinMax 17mA source 12mA sink
# References 
#   IO Expander
#     1. Mcirochip Application Notes AN1043 (GPIO Expander)
#   Matrix keypad
#     2. Microchip Application Notes AN1081 (Matrix Keypad)
#   LCD1602
#     3. ShenZhen YaJingDa Electronics YJD1602A-1 datasheet (2007-09-08)
#     4. PowerTip PC-1602F datasheet (11/10/2004)
#     5. Sitronix ST7066U Dot Matrix LCD Controller/Driver datasheet (01/03/01)
# Raspberry Pi communities
#   eLinux -  http://elinux.org/RPi_Community
#   element14 - http://www.element14.com/community/groups/raspberry-pi
# *****************************************************************************
# 0. Contents ******************************************************************
#
#  1. Program title
#  2. Python imports
#  3. RPi GPIO pin assignment, MCP230xx register base assignment
#  4. Global constants
#  5. GPIO Functions 
#  6. Debugging and documentation functions (beep, print bit/byte, message)
#  7. IO Expander Mcp23008, Mcp23017
#  8. Decimal keypad
#  9. LCD - LCD1602. LCD2004
# 10. Stepping motor - unlpolar steppers 28BYJ48/NPM-PF35/PX245
# 11. Demultiplexor
# 12. Old test functions 
# 13. Main program
# 1. Program Title ************************************************************
ProgramTitle1 = "SPI428 20130221b"
ProgramTitle2 = "FPL428 20130221b"
# 2 Python imports ***********************************************************
import sys
import time
import select
import RPi.GPIO as GPIO
import smbus 
import spidev
smBus1 = smbus.SMBus(1) 
# 3. GPIO and IO Expander pin/address assignments *****************************
I2cBaseAddress0 = 0x20
I2cBaseAddress1 = 0x21
I2cBaseAddress2 = 0x22
I2cBaseAddress3 = 0x23
I2cBaseAddress4 = 0x24
I2cBaseAddress5 = 0x25
I2cBaseAddress6 = 0x26
I2cBaseAddress7 = 0x27
# System A I2C base address assignment *
Mcp23017BaseAddress1 = 0x22 # LED, button
Mcp23008BaseAddress1 = 0x24 # stepping motors
Mcp23008BaseAddress2 = 0x25 # keypad
Mcp23008BaseAddress3 = 0x26 # LCD1602
# System B I2C base address assignment *
Mcp23017BaseAddressSystemB1 = 0x20 
Mcp23008BaseAddressSystemB1 = 0x21 
Mcp23008BaseAddressSystemB1 = 0x21 
# * GPIO pin numbering *
GPIO.setmode(GPIO.BOARD) # Use RPi GPIO numbering, Not BCM numbering
GPIO.setwarnings(False)  # Disable linux's "pin already in use warning"
# * RPi GPIO pin numbering *
# P1-02 5V, P1-04 5V, P1-06 Gnd
# P1-01 3V3, P1-03 I2C SDA1, P1-05 I2C SCL1
# P1-08 UART TxD (Mcp23017 Reset)
# P1-10 UART RxD (Mcp23017 INTB)
# P1-12 RPi GPIO_GEN1 (BCM18) LED (P1-12 > LED > 330R > Gnd)
# P1-14 Gnd
# P1-16 GPIO_GEN4 - Buzzer, 3V3 5mA (P1-16 > Buzzer > Gnd) 
# P1-18 GPIO_GEN5 Button (3V3 > 10K > Contact 1/2 > 330R > Gnd)
# P1-20 Gnd
# P1-22 GPIO_GEN6 - Mcp23008 INT / Mcp23017 INTA   
RPiGPIOgen1 = 12 # Brown  (P1-12, BCM GPIO 18) LED
RPiGPIOgen4 = 16 # Yellow (P1-16, BCM GPIO 23) Buzzer
RPiGPIOgen5 = 18 # Green  (P1-18, BCM GPIO 24) Button
RPiGPIOgen6 = 22 # Blue   (P1-22, BCM GPIO 25) IOx/keypad interrupt
RPiTxD = 8 # Orange (P1-08) UART TxD
RPiRxD = 10 # Yellow (P1-10) UART RxD
# * SCI GPIO pins *
RpiGpioGen10 = 19 # SPI_MOSI
RpiGpioGen9 = 21 # SPI_MISO
RpiGpioGen11 = 23 # SPI_SCLK
RpiGpioGen8 = 24 # SPI_CE0_N
RpiGpioGen7 = 26 # SPI_CE1_N
SpiClockPin = RpiGpioGen11
SpiMosiPin = RpiGpioGen10
SpiMisoPin = RpiGpioGen9
SpiSelect0Pin = RpiGpioGen8
SpiSelect1Pin = RpiGpioGen7
# * peripherals pins assignment *
LEDpin = RPiGPIOgen1
BuzzerPin = RPiGPIOgen4 
ButtonPin = RPiGPIOgen5
TxDpin = RPiTxD
RxDpin = RPiRxD 
# * GPIO input/output pins list *
OutputPinList = [LEDpin, BuzzerPin, TxDpin, SpiClockPin, SpiMosiPin, SpiSelect0Pin, SpiSelect1Pin]
InputPinWithNoPullUpList = []
InputPinWithPullUpList = [ButtonPin, RxDpin, RPiGPIOgen6, SpiMisoPin]
# 4. Global constants *********************************************************
# * Loop counters *
TwoTimes = 2
FourTimes = 4
EightTimes = 8
TenTimes = 10
TwentyTimes = 20
FiftyTimes = 50
OneHundredTimes = 100
TwoHundredTimess = 200
FourHundredTimes = 400
# * Elapse times *
TwentyMilliSeconds = 0.02
FiftyMilliSeconds = 0.05
OneHundredMilliSeconds = 0.1
TwoHundredMilliSeconds = 0.2
TenthSecond = 0.1
QuarterSecond = 0.25
HalfSecond = 0.5
OneSecond = 1
OneAndHalfSeconds = 1.5
TwoSeconds = 2
# * On/Off times *
OnTime = TenthSecond
OffTime = QuarterSecond
ButtonDebouncingTime = QuarterSecond
TestTime = FiftyMilliSeconds
OnTime = 0.1
OffTime = 0.25
# 5. GPIO Functions ***********************************************************
# * Local constants *
# * Nibble naming * 
LowNibble = 0
HighNibble = 1
BothNibble = 2 # full byte of 8 bits
# * Nibble constants *
HighNibble1LowNibble0 = 0xf0
HighNibble0LowNibble1 = 0x0f
# * LED and buzzer states *
Off = False
On = True
# * Button states *
ButtonPressed = False
ButonReleased = True
# * Interrupt states *
Low = False
High = True
# * Setup, read/write GPIO pins *
setupOutputPin = lambda oPin: GPIO.setup(oPin, GPIO.OUT) # set GPIO pin as output 
setupInputPinWithNoPullUp = lambda iPin: GPIO.setup(iPin, GPIO.IN, pull_up_down=GPIO.PUD_OFF) # set GPIO pin as input, no pull up
setupInputPinWithPullUp = lambda iPin: GPIO.setup(iPin, GPIO.IN, pull_up_down=GPIO.PUD_UP) # set GPIO pin as input, with pull up
writeOutputPin = lambda oPin, oValue: GPIO.output(oPin, oValue) # write value to output pin
setupWriteOutputPin = lambda oPin, oValue: (setupOutputPin(oPin), writeOutputPin(oPin, oValue)) # set and write
readInputPin = lambda iPin: GPIO.input(ButtonPin) # read value from input pin
def SetupGPIOpins(outputPinList, inputPinWithNoPullUpList, inputPinWithPullUpList): # set up GPIO pins in InputPinList and OutputPinList
    for oPin in outputPinList:
       setupWriteOutputPin(oPin, Off)
    for iPin in inputPinWithNoPullUpList:
        setupInputPinWithNoPullUp(iPin)
    for iPin in inputPinWithPullUpList:
        setupInputPinWithPullUp(iPin)
def SetupGPIO(): # set up GPIO pins