I appreciate all your responses to this Arduino newbie!
Thank you again, Grumpy_Mike, Septillion & Rob Tillaart,
Well this morning things took a turn for the worse. Smoke!!
To fill you in on the background.
My test bed is 6 six 74hc165 shift registers in series set up with dip switches. Simple enough.
I have been running the clk, clk_enable, shift/load and data from Uno pins 8, 9, 10, 11.
The midi output was taken from pin 1, the TX pin of the Uno.
I wrote a program based around shiftIn, which scanned the switches and when moving the switches sent a note via midi (uno pin 1) to a 'midi to usb' adapter to my PC. The PC plays the corresponding note via software. The USB programming cable was disconnected from the Uno during these tests, and the board was run off a 12 regulated supply to the barrel jack. All working well. It even worked with a real midi keyboard too. Great!
As I said, all was working well and for several days no problem. My only concern was the scanning speed of the shiftIn command, especially when adding many more shift registers, so I followed the suggestion of SPI reading the shift registers.
I made the following changes.
- Loaded the SPI library
- Added the library include for SPI and the SPI.begin() command
- Changed the pin allocation for the shift/load pin to 9. (code reflected this)
- replaced shiftIn commands with SPI.transfer (0)
- Tied clock enable of all shift registers to ground (disconnected from Arduino)
- Moved clk pin of shift registers to sck pin 13 on Arduino
- Moved data pin of shift registers to pin 12 (MISO) on Arduino
- Moved shift/load to pin 9 as previously mentioned in point 3
The new version of the program was loaded (with midi disconnected) and Arduino was powered by USB via computer. All loaded fine. I pressed reset and watched the Arduino reset with all the usual lights.
I completed one more final check of wiring and then unplugged the USB cable from the Ardunio and the PC. It was placed aside.
I connected the USB to Midi cable to the PC, then connected it to the Arduino board. I plugged in the 12VDC power supply. Instantly I knew something was wrong as the TX & RX lights glowed dimly and flickered, (I thought this might be something to do with the SPI, but wasn't sure). A split second later smoke erupted from the Atmega 16u2 chip. (Insert sad face here!).
I checked, and rechecked my connections, but can't find an error. I also can't work out why the USB to serial chip failed as it was not part of what I was doing (or am I missing something?)
Post mortem on the board is the 16u2 is blown & the regulator is only putting out 1.2 volts. Ironically if I feed 5V to the Atmega 328 micro it seems to be still alive and possibly running the last code I downloaded to it. (using a scope I checked the sck and shift/load pins and there is a square wave present).
So, my questions are. What happened?
Is there anything I could possibly enter into code that could fry the 16u2 chip?
Was using SPI library and Midi library together a no, no?
Or, maybe the 12 volt supply just too much for the voltage regulator (I think I may have a clone), and it just chose that moment to fail (unrelated to code or wiring)
Any idea's or thoughts much appreciated.
Best regards to all.