Tuesday, June 23, 2009

8-bit microcontoller programming

I'm once again learning how to do simple embedded programming. I'm using the DEMO9S08AW60E board from Freescale. Unfortunately I'm solving the same problems I ran into last summer I worked on this.

So just in case someone (like me) runs into these problems, I'll blog about them so that the solution can be found via Google.

1. CodeWarrior for Microcontrollers doesn't work with 64-bit Microsoft Vista. It won't even install. Its been that way for several years, no fix coming. Even more annoying, the installer just fails with a cryptic message. Nothing that would indicate that the problem is 64-bit Vista incompatibility.

2. Any time my program tries to run an analog to digital conversion (ADC), the program hangs. I'm not sure why, but I traced the issue to this line in the ADC bean's initialization function:

setReg8(ADC1CFG, 0x7A); /* Set prescaler bits */

Once that runs, I can't do a conversion. The line is auto-generated by the 'processor expert' that comes with CodeWarrior. Every time the processor expert generates the code, I have to comment out this line. I'm not sure yet whatthe 'prescalar bits' are supposed to be set to. I figure when I take the time to understand that, I can code around the issue.

3. Since doing a ADC uses an interrupt, it doesn't work to place the code inside a different interrupt. Measurements have to be done in the main loop.

Now I can blink LEDs and read a 2-axis accelerometer. My not-very-exciting program can change the rate the lights blink depending on how the board is tilted. Next step is to see if the custom printed board a student built last year can be programmed. That board is set up for interfacing robotic servos.