Knowledge on programming the Motorola HC11 MCU

pillage2001

Lifer
Sep 18, 2000
14,038
1
81
I figure that this would be the best place to ask since it's kinda technical. I need to have crash course on programming the Motorola HC11 MCU and wondering if you guys can provide me with any beginners code or site to refer to. I'll be using it for my project this semester. I've got experience in programming Intel MCU but not motorolas. Any help would be appreciated.

Also, how would you maek a motor go bidirectional?? Would inputting a negative voltage make it go the other direction??
 

Krakerjak

Senior member
Jul 23, 2001
767
0
0
Just finished a course on the HC12 MC

I'd say the best refrences are found on the motorola site

like this

****6 meg link

Gotta go, i might be able to find some more resources later.
 

pillage2001

Lifer
Sep 18, 2000
14,038
1
81
Originally posted by: Krakerjak
Just finished a course on the HC12 MC

I'd say the best refrences are found on the motorola site

like this

****6 meg link

Gotta go, i might be able to find some more resources later.

It would be good if you can give me some codes for me to refer. Some beginner kinda codes like how to do addition or using the port to detect an interrupt and what not. :D I'm in for a crash course!
 

ResidentIdiot

Junior Member
Dec 26, 2002
22
0
0
About the motor question. Yes inputing a reverse biased voltage will cause the motor to reverse direction. Best way to do this if you are using a low current source is with two double pole double throw relays dirven through transistors. The theory behind this circuit can be found here:

http://www.temp.eleinmec.com/issue1.htm

 

pillage2001

Lifer
Sep 18, 2000
14,038
1
81
Originally posted by: ResidentIdiot
About the motor question. Yes inputing a reverse biased voltage will cause the motor to reverse direction. Best way to do this if you are using a low current source is with two double pole double throw relays dirven through transistors. The theory behind this circuit can be found here:

http://www.temp.eleinmec.com/issue1.htm

Thanks dude, I'll look into and see what's up. :)
 

Krakerjak

Senior member
Jul 23, 2001
767
0
0
What do you plan on using (compiler) to program the microcontroller?

I used the mcuez compiler for writing and uploading the code.


This is just a simple example program i had to do at the beginning
of last semester, with addition and using the accumulators and memory storage.
Though i used the hc12, but i believe the difference between the two are not that drastic.
I think one difference is 8 and 16 bit operations.

  • ;Lab 1 - Memory Operations

    ;Definitions

    RAM EQU $0800

    Bin_Two EQU %010

    ABSENTRY Lab001

    ORG RAM

    Lab001 ldaa #10
    staa Val_1

    ldab #$CD
    stab Val_2

    ldaa #%10100101
    staa Val_3

    ldaa Ten
    ldab Twelve
    aba
    adda #1
    adda Two
    staa Val_3

    Here bra Here

    ;Constant and Data Storage

    Ten DC.B 10
    Twelve DC.B $C
    Two DC.B Bin_Two

    Val_1 DS.B 1
    Val_2 DS.B 1
    Val_3 DS.B 1

    END

/edit
sorry, it ate up the formatting but it is still readable
 

Krakerjak

Senior member
Jul 23, 2001
767
0
0
The last part of that pdf file lists all the available instructions for the hc11.
And you will also need that reference if you use interrupts, for finding out port addresses for
initializations.

As for interrupts, i have plenty of samples from my own work......depending on the type if system
you would like to use to generate interrupts, such as realtime, timer overflow, input/output capture.

 

natenut

Senior member
Dec 30, 2000
222
0
76
i've had a load of 6800 assembly. You can order books for free from motorola. i could probably send you some if you want, i have the pocket programmers reference book, tells what addresses are what in the single chip and extended modes, invaluable! And i have 2 others too... one is really good. pretty thorough, i used it more than the textbook. it described writing IRQ vectors pretty well as i recall...

Motorola has a online literature service check it out here There are also generic programs that are listed, check the technical bulletins. I'm sure there are a few for stepper motor controllers ;)

when i go home today i'll look up the document numbers for the books i have and pm you or something.



edited for horrable spelling
 

AbsolutDealage

Platinum Member
Dec 20, 2002
2,675
0
0
I took an HC11 class a couple of years ago, all of the lectures in pdf are available Here.

If that is not enough info, the course page is here. you might be able to find some more info there. If you have a specific question, just post it here and I'll do my best. I have some manuals laying around somewhere...
 

pillage2001

Lifer
Sep 18, 2000
14,038
1
81
Krakerjak. I'm not too sure one which program to use. Is there any you would recommend?? I've already gotten the controller today from technologicalarts.
 

Krakerjak

Senior member
Jul 23, 2001
767
0
0
I only have experience using MCUez software, so i dont really have a informed suggestion for you.
The course i took used the HC11 until recently to the HC12, but previously this program was used.



Link
I came across this link in the motorola site, a bunch if info about motor control with a Microcontroller. Take a look, there may be some good stuff to be found.


BTW, what is the controller model number?
 

pillage2001

Lifer
Sep 18, 2000
14,038
1
81
krakerjak, sorry about the lost of contact here. I was kinda busy the past month. Anyways, back to learning the hc11. I've tried a few assembler but none shows the memory map when uploaded to the controller. I've got a hold of a sample code which is pretty easy to understand but I've got a few questions. Here is the codes:

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

org $f800 ;beginning of EEPROM (68HC811E2)

begin:
lds #$ff ;set up stack (essential if you use subroutines)
loop:
ldaa #$40 ;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


Any way to explain this part??

ldaa #$40 ;write logic high to PA6 (turn on LED)
staa $1000
bsr Delay
clr $1000
bsr Delay
bra loop

What does ldaa do??
#$40 =???
What's PA6?? Port A bit 6??

The controller model is the HC11E9. :)
 

AbsolutDealage

Platinum Member
Dec 20, 2002
2,675
0
0

Any way to explain this part??

ldaa #$40 ;write logic high to PA6 (turn on LED)
staa $1000
bsr Delay
clr $1000
bsr Delay
bra loop

What does ldaa do??
#$40 =???
What's PA6?? Port A bit 6??

The controller model is the HC11E9. :)

ldaa=load accumulator a. Your accumulators (on the HC11 there are 2, accum. A and accum. B) are where you store temporary data for immediate manipulation (adds, subtracts, etc). The ldaa command takes a specified value and places it in that accumulator, in this case it is the hex value $40.

#$40 = the Hex value 40. The # signifies that the following data is the actual value you want loaded (as opposed to a reference to a memory address), and the $ signifies a hex value. Translated into binary, this is 0100 0000.

PA6 = taking that binary value (0100 0000), you can see that the 6th bit position (counting from the right, starting at 0) is the only high value. If you measure the voltage across port a, bit6, you will see the value go high.

Hope this helps...
 

blahblah99

Platinum Member
Oct 10, 2000
2,689
0
0
I don't have knowledged on the HC11 mcu, but I do know about the PIC microcontrollers. :)

As for a bidirectional motor, you should do that with an H-BRIDGE, which is nothing more than 4 transistors configured in an "H" configuration, with the load (in this case, the motor), attached across the legs. The gates/base of the transistors are driven by a logic signal, and additional circuitry is needed to make sure all four transistors, or two on the same side, do not turn on simultaneously otherwise it'd be a short from power to ground through the devices.

You can go out and purchase motor drivers in sip packages that can do up to two amps, or you can design the circuit yourself. Since you are using an mcu, I would do the design and use the MCU to control the on/off times.

To be even more nerdy, you can implement PWM on MCU to control the speed of the motor. :) Hope this helps.
 

AbsolutDealage

Platinum Member
Dec 20, 2002
2,675
0
0
To be even more nerdy, you can implement PWM on MCU to control the speed of the motor. :) Hope this helps.

I could probably dig up some HC11 code that I had for a bidirectional variable speed motor controller (PWM controlled).

By the way, don't try to connect the motor directly to the ports on your eval board for the microprocessor (if motor control is something you are looking to do). First of all the controller cannot even come close to providing the amperage necessary to drive the motor. On top of that, directional changes or stopping/starting the motor will cause feedback and completely fry your board. I would look in to getting a professionaly made H-bridge, and then use an opto-isolater circuit to prevent any feedback.
 

pillage2001

Lifer
Sep 18, 2000
14,038
1
81
Originally posted by: AbsolutDealage
Any way to explain this part??

ldaa #$40 ;write logic high to PA6 (turn on LED)
staa $1000
bsr Delay
clr $1000
bsr Delay
bra loop

What does ldaa do??
#$40 =???
What's PA6?? Port A bit 6??

The controller model is the HC11E9. :)

ldaa=load accumulator a. Your accumulators (on the HC11 there are 2, accum. A and accum. B) are where you store temporary data for immediate manipulation (adds, subtracts, etc). The ldaa command takes a specified value and places it in that accumulator, in this case it is the hex value $40.

#$40 = the Hex value 40. The # signifies that the following data is the actual value you want loaded (as opposed to a reference to a memory address), and the $ signifies a hex value. Translated into binary, this is 0100 0000.

PA6 = taking that binary value (0100 0000), you can see that the 6th bit position (counting from the right, starting at 0) is the only high value. If you measure the voltage across port a, bit6, you will see the value go high.

Hope this helps...


Got all those codes recognized. Thanks. :D I'm a dope. I was wondering how could the 6th bit be 0100 0000 instead of 0010 0000. I was counting from 1 to 8 instead of 0bit to 7bit.
:D

Yes, I was thinking of driving the motor with the controller but it seems that the controller I bought does not come with a PWM. So, I guess I would have to generate the PWM myself which is gonna be a pain in the ass. :( Any help will be appreciated in generating it manually. :)

I've done programming in Intel based controllers before and not motorolas. :D
 

cressida

Platinum Member
Sep 10, 2000
2,840
5
81
Originally posted by: blahblah99
I don't have knowledged on the HC11 mcu, but I do know about the PIC microcontrollers. :)

As for a bidirectional motor, you should do that with an H-BRIDGE, which is nothing more than 4 transistors configured in an "H" configuration, with the load (in this case, the motor), attached across the legs. The gates/base of the transistors are driven by a logic signal, and additional circuitry is needed to make sure all four transistors, or two on the same side, do not turn on simultaneously otherwise it'd be a short from power to ground through the devices.

You can go out and purchase motor drivers in sip packages that can do up to two amps, or you can design the circuit yourself. Since you are using an mcu, I would do the design and use the MCU to control the on/off times.

To be even more nerdy, you can implement PWM on MCU to control the speed of the motor. :) Hope this helps.

hehe I just finished building a line follower using the HC12 (similar to HC11) but we did use the PWM to control the motors with h-bridges,
pillage2001, if you are looking for supplies like h-bridges, check out Texas Instruments site, they give out free samples and ship them over night. ;)
 

pillage2001

Lifer
Sep 18, 2000
14,038
1
81
Originally posted by: SoloKid
Originally posted by: blahblah99
I don't have knowledged on the HC11 mcu, but I do know about the PIC microcontrollers. :)

As for a bidirectional motor, you should do that with an H-BRIDGE, which is nothing more than 4 transistors configured in an "H" configuration, with the load (in this case, the motor), attached across the legs. The gates/base of the transistors are driven by a logic signal, and additional circuitry is needed to make sure all four transistors, or two on the same side, do not turn on simultaneously otherwise it'd be a short from power to ground through the devices.

You can go out and purchase motor drivers in sip packages that can do up to two amps, or you can design the circuit yourself. Since you are using an mcu, I would do the design and use the MCU to control the on/off times.

To be even more nerdy, you can implement PWM on MCU to control the speed of the motor. :) Hope this helps.

hehe I just finished building a line follower using the HC12 (similar to HC11) but we did use the PWM to control the motors with h-bridges,
pillage2001, if you are looking for supplies like h-bridges, check out Texas Instruments site, they give out free samples and ship them over night. ;)


I love you.......did I say I love you?? :) I love you. :)
 

pillage2001

Lifer
Sep 18, 2000
14,038
1
81
Alright guys, I've decided to go with the MiniIDE, I opened the program and compiled an example code given in the CD rom and I clicked upload, selected the file and click okie. How do I run the program on the Hc11?? I'm not sure if the program is even downloaded into the EVB. It just went okay and nothing else happen. Is it suppose to respond this way?? I click the reset button on my EVB and this appears.

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

I don't have the tools to check if the MCU is really giving out outputs or not so any input would be appreciated. Is the program suppose to just remain passive after I selected a *.s19 file to upload?? No messages regarding if the upload is successful or not?
 

cressida

Platinum Member
Sep 10, 2000
2,840
5
81
what we did was we use MiniIDE and compiled a txt file and then communicated with the HC12 (brother of HC11) through hyper terminal, I don't remember the specific settings but if you give me a few days, I'll find out.

When it finished loading, it would display (***) depending how big the program was and then went to the memory where the program was stored to test the program

i.e. g800 where we usually stored ours.
 

Mday

Lifer
Oct 14, 1999
18,647
1
81
god, i thought i was the only one using the 68hc11 in class. what a craptacular pos.

i hate assembly.
 

Fandu

Golden Member
Oct 9, 1999
1,341
0
0
Originally posted by: pillage2001
Alright guys, I've decided to go with the MiniIDE, I opened the program and compiled an example code given in the CD rom and I clicked upload, selected the file and click okie. How do I run the program on the Hc11?? I'm not sure if the program is even downloaded into the EVB. It just went okay and nothing else happen. Is it suppose to respond this way?? I click the reset button on my EVB and this appears.

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

I don't have the tools to check if the MCU is really giving out outputs or not so any input would be appreciated. Is the program suppose to just remain passive after I selected a *.s19 file to upload?? No messages regarding if the upload is successful or not?

Buffalo is the HC11 ROM program. after you see the welcome message, you can hit enter and get a command prompt. There are many commands for manipulating the memory, flags, and registers, and it also has an assembler built in. So if you want to view memory, use the MD command. Say your program starts at $C000, then you would use MD C000 <cr>. You can modify the registers using the RM command. To modify the PC, you use the command RM p<cr>C000<cr>. To start your program, you can either set the PC and type GO or just use GO xxxx where xxxx is the starting address of your program.
 

Krakerjak

Senior member
Jul 23, 2001
767
0
0
oy, miniIDE.
This is what we use now with our HC12.

WHat you need to do is:

1) Connect to your board using the terminal window or the hotkey button
2) Then in the terminal window hit enter so you get to the ">" prompt
3) Now, with the HC12 i type LOAD <enter> and this brings me to the next line
4) Then i clicck the download button and select a .s19 file and the prompt will show a couple of **
5) In the program you might have defined a location in ram for your program is to be stored (ie. $800 seems to be the standard)
if you dont do this just add "org $800" before the first instruction in your program.

To edit the register contents you can just type "a 5A" or "b 33" or "d 1234" (all considered hex values)
To run the program i use "g 800" which takes me to the start of my program in memory and runs the instructions located there.

The thing is, the hc11 may have different commands. My hc12 uses debug onboard for commands which may be different