Richard Snook

MC68HC908QY4 Assembly Help Please

Discussion created by Richard Snook on Jun 23, 2007
Latest reply on Jun 25, 2007 by Richard Snook
A couple of years ago, I was involved at work in a project using the MC68HC908QY4 8-bit microcontroller. It was a very simple project, little more than a timing circuit, with the code all written in Assembly, but I can see another use for the same circuit with similar code, but using more of the device's functionality. My aim is to at least create a prototype using a spare existing unit and then present it to my colleagues to prove the concept.

I have to admit my lack of much experience or education on microcontrollers or the use of Assembly.

Some areas I think I have now got to grips with, such as the commands to get the ADC to sample, but there are several areas I am unsure how to do. Is there a tutorial on the techniques to do the basics, or a recommended book? The sorts of things I am unsure of are:

I want to average several ADC readings, but how do I add 8-bit numbers together, when the result will probably be more than 8 bits? Is there a standard technique for this in assembly? Do I have to look at the carry bit and "manually" increase a bit of some other register each time? I think I understand that I can use the H:X register to manipulate a 16-bit number, but I can only see the AIX command, to add an immediate value, not a command to add another variable such as an ADC reading.

If I take say 8 readings, and have managed to add them together, how can I right-shift the total to divide by 8? I can't see how I right-shift a word across a byte boundary, I can only see how to right-shift a byte.

When I take an ADC reading, which takes several clock cycles, I understand that I can do other work, e.g update my total using the most recent value, and then use an interrupt to know that the next value is ready. Is there an example of this technique that I could try to follow.

Because the previous project was in Assembly, and all the documentation supports it, I would prefer to stick with Assembly for this new project.

If I'm completely out of order expecting to do 16-bit work with an 8-bit device or expecting answers to these sort of things, I apologise, but I'd appreciate being steered in a useful direction.

I believe that this microcontroller is soon to be obsolete (although I may be wrong) but because the hardware exists in the current design, I would like to prove (or disprove) the idea with what we have. In the longer run, a guess we'd pick a newer device.

Any help would be greatly appreciated.