Knowledge on programming the Motorola HC11 MCU

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

Fandu

Golden Member
Oct 9, 1999
1,341
0
0
Krakerjak: There look like a few differences, eg: to load a program, you have to use the 'load t' command for "load terminal", just load will not suffice. But it's still 6800 no matter how you slice it. :)
 

pillage2001

Lifer
Sep 18, 2000
14,038
1
81
Originally posted by: Shark_II
Take my school project and run!

http://home.austin.rr.com/jeradc/68HC11.html

I'm running win2k. :p

I'll try running the commands by krakerjak and FAndu and see what's up.
 

pillage2001

Lifer
Sep 18, 2000
14,038
1
81
Alright, I've tried the terminal thingy. I tried loading it but it came up with these msgs.

BUFFALO 3.4 (ext) - Bit User Fast Friendly Aid to Logical Operation
>LOAD

No host port
>S0030000FC
S113F800CF00FF86407A10000
Too Long
>016
S10DF810F2CDFFFF03020326FB3DC7
S
Too Long
>09030000FC

I typed LOAD and it tells me no host port?? Then I just select a small S19 file to upload and the msgs came out instead of the **. What gives??
 

pillage2001

Lifer
Sep 18, 2000
14,038
1
81
Alright guys, I think I have a major problem here.

I've tried the LOAD t and it worked BUT, it doesn't place the codes at where I want the codes to be at. My controller unit is the 68hc11e9bcfn2. I referred to the manual and it said that the starting EEPROM is at $b600 which is what I put my ORG as but when I tried to download the file, it just hangs there. There are two download options, one is just download file while the other is download file to EEPROM. WHich should I use?? I tried using the download to EEPROM command but it just hangs there too.

I tried address 0800 and it downloaded. Here are the feedback given from the MCU.

This is the exact EVB I'm using.


BUFFALO 3.4 (ext) - Bit User Fast Friendly Aid to Logical Operation
>load t
rom-B900
>

Then when I do a MD b900

B900 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
B910 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
B920 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
B930 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
B940 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
B950 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
B960 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
B970 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
B980 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

This came out. What gives?? Am I doing it right?? But when I do a MD 0000

0000 CF 00 FF 86 FF 7A 10 00 07 07 79 10 00 07 02 20 z y
0010 F2 CD FF FF 03 02 03 26 FB 3D FF FF FF FF FF FF & =
0020 FF 7E FF FF FF FF FF FF FF FF FF FF FF FF FF FF
0030 FF FF FF FF FF FF FF FF FF D0 FF FF 77 FB FD 5F w _
0040 B9 00 FF FF FF FF FF EF FF FE FF FF E4 E4 6D E3 m
0050 D4 00 E4 6D E3 D4 00 57 07 20 E5 02 E8 10 E1 AA m m X (
0060 B9 00 FD 5F 77 FB FF FF D0 00 41 6D 64 20 30 30 _w Amd 00
0070 30 30 0D 30 46 43 0A 6C 6F 61 64 20 74 0D 30 33 00 0FC load t 03
0080 30 32 30 33 32 36 46 42 33 44 42 46 0A 53 4D 44 020326FB3DBF SMD

I checked the lst file and the program is being loaded at the 0000 till the highlighted part.

Here are my codes.

*file: simple2.asm
*A simple HC11 program with a subroutine.
*It continuously blinks the LED on PA6.

org $b900 ;beginning of EEPROM (68HC811E9) The actual starting point is at b600 but it'll hang there.

begin:
lds #$ff ;set up stack (essential if you use subroutines)
loop:
ldaa #$ff ;write logic high to PA6 (turn on LED)
staa $1000
bsr Delay
clr $1000
bsr Delay
bra loop

*define the delay subroutine
Delay:
ldy #$ffff
D1: dey ;the extra iny and dey instructions are meant to add
iny ;extra cycles, giving about a half-second total delay
dey
bne D1
rts

*define the reset vector to point to start of program
org $fffe
fdb begin


I'm desperate now. :(

Does the run and boot switch on the EVB matter???
 

Fandu

Golden Member
Oct 9, 1999
1,341
0
0
Tell me what EEPROM stands for. Then tell me how you plan to program it. As the 'ROM' part implies, it's READ ONLY, ie, you CANNOT WRITE to it. Programs go in RAM, end of story. Find out where ever you have a RAM block, then ORG your program there.

Also, it looks like you typed 'rom-B900' after the load t command..?? after typing load t, you then use your terminal program to send the .s19 file after which you'll be returned to buffalo.

Also, your delay routine looks like it will be an infinite loop [Edit: I missed the extra DEY in there] and you have definitly made a mistake with the FDB directive. FDB stands for Form Double Byte, and it will store a 16bit number at it's current location. The code you have will place 0xB900 at the location 0xFFFE and 0xFFFF. Other than not doing anything usefull, you are trying to overwrite the buffalo ROM! Buffalo's ROM space most likely goes from 0xE000 to 0xFFFF. There's a very good reason why you can't overwrite the reset vector. If you did manage to change it, and you ran your program, how would you ever manage to get back to buffalo?

You might want to have another look at your memory map for the EVB. Your entire program must be placed in User RAM.
 

pillage2001

Lifer
Sep 18, 2000
14,038
1
81
Originally posted by: Fandu
Tell me what EEPROM stands for. Then tell me how you plan to program it. As the 'ROM' part implies, it's READ ONLY, ie, you CANNOT WRITE to it. Programs go in RAM, end of story. Find out where ever you have a RAM block, then ORG your program there.

Also, it looks like you typed 'rom-B900' after the load t command..?? after typing load t, you then use your terminal program to send the .s19 file after which you'll be returned to buffalo.

Also, your delay routine looks like it will be an infinite loop [Edit: I missed the extra DEY in there] and you have definitly made a mistake with the FDB directive. FDB stands for Form Double Byte, and it will store a 16bit number at it's current location. The code you have will place 0xB900 at the location 0xFFFE and 0xFFFF. Other than not doing anything usefull, you are trying to overwrite the buffalo ROM! Buffalo's ROM space most likely goes from 0xE000 to 0xFFFF. There's a very good reason why you can't overwrite the reset vector. If you did manage to change it, and you ran your program, how would you ever manage to get back to buffalo?

You might want to have another look at your memory map for the EVB. Your entire program must be placed in User RAM.

Alright, here goes, I've tried loading the *.s19 file into the RAM and it won't continue until I have to reset it. The rom -B900 is not written by me, it just appeared when I choose a file to upload. Is there any other way to do it cause eash time I open a dialog box, the rom- will appear. When I upload at 0800, it'll go rom-0800. If I upload at 0020, it'll just go rom- and hangs there till I press reset. I'm going crazy trying to figure out how to program it. Then when I somehow got it into the starting address of the RAM, I typed go 0000 (0000 is my starting address for RAM) and ^B appears or some random ascii character. :(

The user RAM is placed at the 0000 address. That's what the manual says, the EEPROM is placed at the B600 location. So I shou;d jkust dump the FDB line and go straight to END??

 

Fandu

Golden Member
Oct 9, 1999
1,341
0
0
OK, I just looked through the machine code you posted, and the op-codes are all wrong, those look like HC12 op-codes. What assembler are you using? Try using AS11 as it's the most basic one out there. You can check out my course webpage for it.
 

pillage2001

Lifer
Sep 18, 2000
14,038
1
81
Originally posted by: Fandu
OK, I just looked through the machine code you posted, and the op-codes are all wrong, those look like HC12 op-codes. What assembler are you using? Try using AS11 as it's the most basic one out there. You can check out my course webpage for it.

:eek:, I think you caught me there. I just checked the MiniIDE and the assembler by default is for the HC12. I just switched it to HC11. I'll see how it goes in a few.

What about the BOOT and RUN switch?? The Single chip mode?? The manual that came with it says that I need to switch the RUn to BOOT whenever I press reset and before I run the program?? Am I required to do so even if I'm using MiniIDE??

Some more questions, I noticed that I only have 512bytes of RAM, I found this from where I bought the MCU, do I just simply buy one and hook it up?? I did not find any guideo n how to hook the extra 32k up. Anyone has any experience??
 

Fandu

Golden Member
Oct 9, 1999
1,341
0
0
Depending on what your doing, 512 bytes may very well be enough memory. Your program above is only 26 bytes.....

Anyways, as far as expansion cards go, I have absoutly no idea. That page says that the memory card decodes to 0x0000 to 0x7FFF, which makes me think that you may have to disable the 512 bytes you already have.... but I really don't know. I can interface any memory chip config you want directly with the cpu, but it looks like they have built some kind of expansion system that likely changes things.

Also, at the end of your program execution, you should use the SWI instruction to return to Buffalo. The program that you have there is an infinite loop, so you'll just have to reset the board, but normally you would use a swi instruction to terminate your program

As far as the boot and run switch goes, your manual sounds correct. You could try leaving it in each mode and see what happens, you can't hurt it. And the uP doesn't care at all what assembler your using, it doesn't even know.
 

AbsolutDealage

Platinum Member
Dec 20, 2002
2,675
0
0
Originally posted by: Fandu
OK, I just looked through the machine code you posted, and the op-codes are all wrong, those look like HC12 op-codes. What assembler are you using? Try using AS11 as it's the most basic one out there. You can check out my course webpage for it.

Those opcodes look fine to me for HC11...
 

AbsolutDealage

Platinum Member
Dec 20, 2002
2,675
0
0
What about the BOOT and RUN switch?? The Single chip mode?? The manual that came with it says that I need to switch the RUn to BOOT whenever I press reset and before I run the program?? Am I required to do so even if I'm using MiniIDE??

You should not have to alter anyting between loading the program and running the program. You are running in single chip mode (as opposed to having more than 1 HC11 "teamed" together). The BOOT and RUN switches (if I remember correctly) are for running a program on startup (instead of the buffalo monitor).


Some more questions, I noticed that I only have 512bytes of RAM, I found this from where I bought the MCU, do I just simply buy one and hook it up?? I did not find any guideo n how to hook the extra 32k up. Anyone has any experience??

onboard RAM should be MORE than enough for just about any application. I had an enormous program for the HC11 that did rudimentary speech recognition, and it still fit into the onboard RAM.

As for your problem, start your program at $c000. That should be pretty universal as far as the EVB's go. You are not going to want to load data in the EEPROM, you load your program into User RAM. Try substituting org $c000 into your code and see what happens

load t
(download file)
(reset)
g $c000
 

Fandu

Golden Member
Oct 9, 1999
1,341
0
0
Originally posted by: AbsolutDealage
Originally posted by: Fandu
OK, I just looked through the machine code you posted, and the op-codes are all wrong, those look like HC12 op-codes. What assembler are you using? Try using AS11 as it's the most basic one out there. You can check out my course webpage for it.

Those opcodes look fine to me for HC11...

I think you better re-check those, they are definitly wrong. The op-code for LDS #$FF is 8E 00 FF, not CF 00 FF. STAA $1000 is B7 10 00, not 7A 10 00. And so on. Here is the fully assembled file for the HC11.


0001 b900 ORG $b900
0002 begin
0003 b900 8e 00 ff lds #$ff
0004 loop
0005 b903 86 ff ldaa #$ff
0006 b905 b7 10 00 staa $1000
0007 b908 8d 07 bsr Delay
0008 b90a 7f 10 00 clr $1000
0009 b90d 8d 02 bsr Delay
0010 b90f 20 f2 bra loop
0011
0012 Delay
0013 b911 18 ce ff ff ldy #$ffff
0014 D1
0015 b915 18 09 dey
0016 b917 18 08 iny
0017 b919 18 09 dey
0018 b91b 26 f8 bne D1
0019 b91d 39 rts
0020
0021 fffe ORG $fffe
0022 fffe b9 00 fdb begin

 

pillage2001

Lifer
Sep 18, 2000
14,038
1
81
Fandu's right, I assembled the code using the hC11 assembler and it was definitely different. It's working for now. :) Time to work on the project. Anybody has any idea how to work a stepper motor with it?? I got a documentation from motorola and it was really long. :D

Thanks for the help!
 

cressida

Platinum Member
Sep 10, 2000
2,840
5
81
Originally posted by: pillage2001
Fandu's right, I assembled the code using the hC11 assembler and it was definitely different. It's working for now. :) Time to work on the project. Anybody has any idea how to work a stepper motor with it?? I got a documentation from motorola and it was really long. :D

Thanks for the help!

eh, just got back from the lab, but at the lab they had some example code for stepper motors.
 

pillage2001

Lifer
Sep 18, 2000
14,038
1
81
Originally posted by: SoloKid
Originally posted by: pillage2001
Fandu's right, I assembled the code using the hC11 assembler and it was definitely different. It's working for now. :) Time to work on the project. Anybody has any idea how to work a stepper motor with it?? I got a documentation from motorola and it was really long. :D

Thanks for the help!

eh, just got back from the lab, but at the lab they had some example code for stepper motors.

Mind sharing? :) I just need the 4bit sequence to rotate the motor left and right. The motor we used is obsolete so I cannot find any details online. :(
 

pillage2001

Lifer
Sep 18, 2000
14,038
1
81
Originally posted by: SoloKid
no problem, I'll try to look for it tomorrow.

Please PM me if you do find it. I've got a few questions in my mind.

1) Are all stepper motor driven by the same type of sequence?? The stepper motor I have has 6 wires connected to it. 2 for power and ground and the other four are the bits to drive the motor. Are they all the same for different type of motor?
 

xyion

Senior member
Jan 20, 2001
706
0
0
Ok, I read through the majority of this tread, and don't know if you actually found software that works with the HC11 yet. I'm taking an introduction to Microcomputers class at Penn State University, and we do use the HC11 for the class. To code, we use Programmers File Editor, and to compile we use AS11 and/or AS11M (for *.lst files). I might be able to get you the zip file that we used, as the prof gave it to us at the beginning of the semester.

That said, I have no idea how to run a stepper motor (too lazy to read up on it sort of deal), but I may be able to help you with any other HC11 problems you might be having. I am just learning this as well, so don?t expect toooooo much (my own projects drive me insane)
 

AbsolutDealage

Platinum Member
Dec 20, 2002
2,675
0
0
I think you better re-check those, they are definitly wrong. The op-code for LDS #$FF is 8E 00 FF, not CF 00 FF. STAA $1000 is B7 10 00, not 7A 10 00. And so on. Here is the fully assembled file for the HC11.

Yup, my bad. It's been a while... but I went over some old HC11 stuff I had laying around... you're right.

Anyways, getting back to the problem.... a quick stepper motor tutorial is in order. A stepper motor contains several sets of coils (a middle-of-the-road motor sports 4 "sets" of coils, which correspond to the 4 wires). These coils are arranged around the outer rim of the motor. The coils are arranged in a round robin fashion (say, a #1 coil at 0°, a #2 coil at 7.2°, a #3 coil at 14.4°, a #4 coil at 21.6°, and (starting over) a #1 coil at 28.8°, etc.).

When a set of coils is energized, the motor head will move to the closest energized coil. When 2 sets are energized, it will move to a position in the middle of the 2 coils (this only applies to adjacent coils, for coils more than 1 position apart, the motor will have trouble deciding the correct position). Thus, with the motor described above (with coils at the prescribed positions), it is possible to have a granularity of 3.6°. Therefore, it will take 100 steps to move around a complete circle.

Now, with your specific motor, you will have to guess and check which wires correspond to which sets of coils (they usually will come out of the housing in the right order). All that remains is to realize the specific sequence of energizing that will create rotary motion. Energize wire #1, energize wire #1 and #2, energize just wire #2, energize wire #2 and #3, etc.

More technically, the wires are in practice named A-D... here is a table for easy copy/paste.

Stepper Motor Coil Energizing Pattern for CW and CCW Rotation

CW Rotation
D C B A
0 0 0 1
0 0 1 1
0 0 1 0
0 1 1 0
0 1 0 0
1 1 0 0
1 0 0 0
1 0 0 1

CCW Rotation
D C B A
0 0 0 1
1 0 0 1
1 0 0 0
1 1 0 0
0 1 0 0
0 1 1 0
0 0 1 0
0 0 1 1
 

Fandu

Golden Member
Oct 9, 1999
1,341
0
0
Interesting, I never thought about how those actually worked and how you would control one.
 

Krakerjak

Senior member
Jul 23, 2001
767
0
0
Now that you are pretty much on your way, what do you plan on driving with the motor???
What is the project you have to complete?

I had a project where we had to create an elevator, with 5 floors. Each floor has a call button (up or down)
as well as floor sensors, and shutdown sensors if the elevator car goes too high or too low. We controlled it
using the parallel port and a rather long C++ program. It had to choose which floors to go to if more than one
was in queue to be the most efficient.

Thinking of it now, id probably be able to control the same
thing using a microcontroller with about half the effort.....or at least half the frustration.
 

pillage2001

Lifer
Sep 18, 2000
14,038
1
81
We;re using a stepper motor to balance an inverted pendulum on the rail. The stepper motor we get is from a Epson printer. Anybody have any idea what are the connections like for a tepper motor?? It has 6 wires. I believe there are 4 input lines and 2 power, ground lines but I don't know what color is for which. It's a very old printer.

ANy ideas??? I tried looking for the stepper motor online but can't find any info on the type that I have. The color of the wires are, white black grey red orange brown/yellow(Can't make it out)

Any ideas?? If I connect it wrongly, it'll short the MCU and reset it.
 

Krakerjak

Senior member
Jul 23, 2001
767
0
0
Sounds interesting.

I suggest you test the motor using a regular supply, and sequencing the bits to figure out which wire is which.

If i had to guess, it is most likely that white, grey, orange, brown are your 4 bits.......and the red/black is your +V/GND?
(Why would you need a +V when you have the bits?)

If you have the supplies just wire up 4 pushbuttons, connect the wires where needed and test it out till you get it down. I suggest putting a piece of tape on the rotor piece so you can tell its moving since the steps are verrry small testing it this way.
......or you could be a fearless engineer and connect it up to your MCU and go, but that could cause more trouble than the safe way.

/edit

This LINK should have everything you need to know about getting your motor figured out. Looks like you have a 4 phase unipolar SM, check it out.

edit/
 

joburnet

Senior member
Aug 1, 2000
722
0
0
I took a class on programming the HC11 at VA tech about a year ago and I still have a bunch of programs and stuff on my filebox. The address is www.filebox.vt.edu/j/joburnet/ but have fun trying to figure out what it all is. If you have any questions then e-mail me but it looks like you should have plenty.
 

pillage2001

Lifer
Sep 18, 2000
14,038
1
81
Originally posted by: Krakerjak
Sounds interesting.

I suggest you test the motor using a regular supply, and sequencing the bits to figure out which wire is which.

If i had to guess, it is most likely that white, grey, orange, brown are your 4 bits.......and the red/black is your +V/GND?
(Why would you need a +V when you have the bits?)

If you have the supplies just wire up 4 pushbuttons, connect the wires where needed and test it out till you get it down. I suggest putting a piece of tape on the rotor piece so you can tell its moving since the steps are verrry small testing it this way.
......or you could be a fearless engineer and connect it up to your MCU and go, but that could cause more trouble than the safe way.

/edit

This LINK should have everything you need to know about getting your motor figured out. Looks like you have a 4 phase unipolar SM, check it out.

edit/

We've tested it out on the MCU. My partner has hooked up everything. The motor turns very minimally. I think we did not pump out enough voltage to get it going. It was pumping out 5v. We're going for 12v tomorrow with a transistor to boost the voltage.

Thanks for the help man. I'll keep you guys posted. :)