Mountain Girl and I are working on the Hamsters. We've put together the hardware, modified the software, synthesized a control circuit onto a CPLD, and now we're trying to figure out why it doesn't work.
We knew it wasn't going to work. We were prepared for that.
The first order of the day is to trace the problems back to the One True Error, the source of the cascading series of problems that leaves our pile of wires and circuitry with the status of junk. We go wrong at first by assuming that when we program the Hamster to write a '1' out to the Port F Pin 5, which we must use because that's how it's wired on the printed circuit board (to do otherwise would involve mutilating the board and soldering wires onto scratched up traces), the Hamster does indeed write a '1' out to that pin. We used the WriteBit() function, after all. It should write out a bit, right?
Once we finally discard that assumption, we put a probe on the pin and find that we get no '1'. We use assembly language and write a '1' to the pin by force. No '1'. We double check our Port F initializations and initialize Every Single control register to make sure that the port is set up to do what we want.
Port F ignores us.
We make pointed comments while casting sidelong looks just over the microcontrollers.
"Gee. I wonder why there are no hammers in the lab."
"Bad Hamster, no kibble."
We read more documentation. At this point we have six browser windows open to the various documentation files for the Hamster microcontroller. Repeatedly we are informed that Port F can be configured for output and how to do it. Repeatedly none of this works. Based on some characteristics of the more special control registers, I become suspicious that this is a problem with the data not getting clocked out to the port ever. I think that the "pclk" that is the default is a peripheral clock that does not actually exist. (The more I think about it, the more certain I become. We should probably have examined the other timing options but we were getting tired. Okay, so I just rechecked the documentation because I live to read documentation and that is not the problem. I think that the reference to the conflict between Ports A and F is perhaps not as complete as it ought to be.)
At last we review what did work. Port F Pin 5 was used to send out a pulse-width modulation signal. We find that if we use the PWM() function, we can set the duty cycle to 100%, making the pulse high all the time and thereby giving us our '1'. When we want a '0' we set the duty cycle to 0%.
This works.
I don't like it.
483 words | February 17, 2005 11:03 PM | Ivory tower