I'm running into a problem with interfacing a PS/2 mouse and I think the source of the problem is related to timing errors. My current setup is to have the PS/2 mouse data and clock line connected to a bidirectional MOSFET voltage level converter (http://www.hobbytronics.co.uk/mosfet-voltage-level-converter) into 2 pins on a 48-pin MSP430F5510. As for the code, I'm using Arduino's PS2Mouse library because it is known to work.
It's probably bad practice but I wrote a digital I/O class similar to Energia to get the PS/2 library working (http://pastebin.com/Wkumn6v6) I've read Chapweske's write-up on PS/2 interface in general and look at other microcontroller's code so I guess I have fair understanding of what's needed to be done.
This is the code I'm working with for the PS/2. It's pretty much the Arduino library code, except it's for use in C. http://pastebin.com/VRZBTiVX. This morning I tried to use Arduino PS/2 library with Energia for MSP430 Launchpad without a crystal and it worked (now it doesn't anymore) so it shows the bidirectional converter works and the problem resides in the timing.
The clock on the 5510 is running at ~8MHz and UART running at 38400 baud. Yesterday somehow I managed to get TPwrite() (write to PS/2) to work by modifying the constant in __delay_cycles() to 5 in delay_us(). With 5 instead of 8, the delay_us() was spot on. Today, TPwrite() stops working altogether.
So my questions are:
1. When working with communication protocols, how would you debug? Since timing is critical, pausing and stepping through the code wouldn't work.
2. Is there a way to output the MCLK/SMCLK onto a pin on the MSP430F5510? I'm using Olimex's MSP430-T5510 which uses a 48-pin one and doesn't have P2.2 which normally outputs SMCLK.
I have a DPScope SE, which is a cheap USB oscilloscope. It has a few logic analyzer pins but so far I've found it be less than useful.