I wish you Merry Christmas and a Happy New Year. Let the coming year be prosperous joyful for all of us.
Pretty much every time I tried to work with some sort of digital interface I run into some kind of trouble where a logic analyzer would have saved me hours of blind debugging and posting to various forums. Same thing happened when I decided to try the TMP121 temperature sensor from TI which has an SPI interface. It was the first time I worked with SPI on a pic32 and as expected nothing worked for the first try. The code for setting the SPI interface and reading from it seemed correct, I took it from the “32 bit peripheral lib user guide” from Microchip.
//configure SPI OpenSPI1(SPI_MODE16_ON | SPI_SMP_ON | SPI_CKE_ON | MASTER_ENABLE_ON | CLK_POL_ACTIVE_HIGH | SEC_PRESCAL_8_1 | PRI_PRESCAL_16_1, SPI_ENABLE); //start reading T1 mPORTEClearBits(BIT_0); // pull CS low to prepare for reading while(!DataRdySPI1()); T1 = ReadSPI1(); // read 16 bit word mPORTESetBits(BIT_0); // pull CS high
So what else could be wrong ? Well at this point it could be a faulty sensor or incorrect use of the SPI interface maybe I wasn’t generating the clock correctly or maybe some wiring issue. This is the point where you need to have a logic analyzer. While I don’t have a proper logic analyzer I do have a PicKit2 and it can emulate a 3 channel, modest logic analyzer. I hooked up one of channels to the SCK pin and I noticed I wasn’t getting any clock signal. But why isn’t the clock being generated ? The answer came from the Microchip forums, the guys there pointed out that in order to generate the clock signal you have to issue a dummy write. By issuing a dummy write you start generating the clock and you can do the reading. So I added a new line to the code and tried again:
//configure SPI OpenSPI1(SPI_MODE16_ON | SPI_SMP_ON | SPI_CKE_ON | MASTER_ENABLE_ON | CLK_POL_ACTIVE_HIGH | SEC_PRESCAL_8_1 | PRI_PRESCAL_16_1, SPI_ENABLE); //start reading T1 mPORTEClearBits(BIT_0); // pull CS low to prepare for reading SPI1BUF = 0x00; // this sends a 0x00 just to make the clock toggle in order to read while(!DataRdySPI1()); T1 = ReadSPI1(); // read 16 bit word mPORTESetBits(BIT_0); // pull CS high
This time I also connected a second channel from the logic analyzer to the SDI pin on the pic32 (data in) and it worked đź™‚ , here is the capture:
As you can see on channel 2 there are 16 clock cycles corresponding to the 16 bit word sent by the TMP121 and on channel 3 connected to SDI(data in on pic32) is the actual binary temperature. If we analyze the data on Ch3, for every falling SCK edge we get 0001101010100000 we can discard the first bit cause its the sign bit (0 = positive , 1 = negative) and plug the rest of the bits in a calculator just to check the data.
Next we convert to decimal and we get a value ofÂ 6816.
6816 is not quite the number that we were looking for, but remember the data is represented in two’s complement so we have toÂ divide it by 256 to get the actual temperature in degrees C.
The result after division by 256 is 26.625 degrees C. This was the room temperature at the time of this test. From here on everything is simple, I know I’m getting the right data out of the sensor its just a matter of processing and using it. And here is a picture of the PCB I made for the TMP121 in SOT23-6 package. Probably one of the smallest PCB I made at home, 30×10 mm.
Now I’m seriously thinking about getting the Logic Sniffer from Dangerous Prototypes, it’s a must have.
I first heard of it from Ian, I’ve gotta say this opens allot of possibilities for people to work with the MSP430.
Grace is a graphical configuration tool for MSP430 developers for setting up integrated peripherals such as ADCs, OpAmps, Timers, Clocks, and other modules. This tool is a free and open source, eclipse-based plug-in for Code Composer Studio. The Grace Beta currently supports all MSP430 Value Line devices (MSP430G2xx) as well as the MSP430F2274 device.
I was thinking about starting some projects on the MSP430 in the near future and one big problem is that I would have to read allot of datasheets and other info to get me started, and there isn’t always time for that. Grace might solve that problem for you and allow you to skip the hard work. Let me know if you’ve tried it. I’m especially interested on how it can interact with one of their MSP430+RF SoC.
The Logitech Z-2300 is a 200 watt THXÂ®-certified 2.1 speaker system with a 8-inch long-throw subwoofer. I’m not going to tell you about how good or bad the system is because this is not a review, there are plenty of good reviews out there, just google for one. My Z-2300 worked perfectly for about 2 years but during the thirds year or so I started noticing a small hum coming out of the subwoofer no matter if it was a low or high volume, input connected or disconnected. It bothered me for quite some time but then I got used to it, until recently when I felt that the hum had increased its intensity and I couldn’t stand it anymore.
In the past few weeks I was constantly thinking that I need to fix it someday but I was thinking that I’m going to need to replace some capacitors that’s going to need some de-soldering, getting the right replacement soldering back together, this proved to be a wrong assumption as the fixing was much easier.
First of all you should start by removing the front grill. I used some small flat screwdrivers inserted between the grill and the plastic ring, first lfet-right, next top-bottom. I think the grill was glued a bit and took some force to get it to move. I managed to take mine out without any visible scratches or dents. There’s also a video on youtube, the guy recommends a hair drier: http://www.youtube.com/watch?v=cqbkMGPtZUU
Next you have to remove the 8 screws holding the woofer in place, after those are out slowly take out the woofer, hold it strongly cause the big magnet on the back might jump&stick to the toroidal transformers on the bottom of the subwoofer case. Remove the connectors and take the woofer out, this will allow us to pull the PCB on the back further out so we can work on it. If the zip ties holding the cable secured to the box are too tight you can cut them, but be careful not to cut any cable, and make sure you have replacements cause you don’t want the cable to be moving aroundÂ synchronizedÂ with the bass đź™‚
Next move on to the back of the subwoofer. Here you’ll have to take out all of the screws(22 of them) surrounding the metal plate. Now the backplate is kind off glued and stuck if you never opened it before so you’re gonna have to grab the heatsink firmly and give it a good twist as well as pulling on it, but be careful cause all the wires are attached to it and you can only pull it back about ~4 inches. After it pops out, look for the wires that are keeping you from pulling it further back. I had the woofer wires (black+red), I had to cut some more zip-ties to release them, and I could finally take a look at the board.
Although its hard to spot in the picture above, I spotted a potential problem. It’s circled in red in the photo. It should help you understand whether your problem is the same as what I have experienced, it’s one of those crimping connectors used to secure 2 cables together.The black cable (ground) originally comes from the toroidal transformer placed on the other side of the box. Then when it comes close to the PCB I don’t why the guys from Logitech decided to split it, and have another small piece of black wire going to the PCB. I really don’t understand, couldn’t they’ve just used a whole piece of cable? Anyway as I was talking to a friend of mine, this seems to be a very common cause for getting noises in amplifiers, broken ground circuit.In my case the crimping connectorÂ wasn’tÂ holding the cables tight anymore so there was an imperfect ground connection from the transformer to the PCB.
In the above pictures you can see how I removed the crimping connector and I soldered the two ground wires together. Next some heat shrink tubing to protect the connection and the noise was gone. Put everything back together and now I can even Â pump up the volume to the max with the inputÂ disconnectedÂ and there is very little noise coming out of the speakers. No wonder the z-2300 has SNR >100 dB and they’re Â THXÂ®-certified. I hope this helps you if you have the same problem.
The new MPLAB X IDE from Microchip, still beta looks pretty cool and with new functions like code auto-complete, the ability to preselect which tools are used on which project, history, its gonna be a hit. I think the most useful function in MPLAB X is the history which allows you to go back and removeÂ modificationsÂ you’ve made to the code. The code auto-complete is also nice. Let’s hope it passes the beta stage soon. Watch the video to learn more.