Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

68HC11 - initializing ports

Status
Not open for further replies.
Hey there,

I'm now playing with the EVBU and like the PIC, I'm now trying to light up one LED from a port.

As usual, this is from PORTB. But the LED is still lit on despite I sending in the 0000 into the PORTB.

Anything missing?

Here's the code:
Code:
        ORG  $2400
START    LDAA    #$FF
    STAA    $1004
    BRA      *

:confused:
 
Hey there,

I'm now playing with the EVBU and like the PIC, I'm now trying to light up one LED from a port.

As usual, this is from PORTB. But the LED is still lit on despite I sending in the 0000 into the PORTB.

Anything missing?

Here's the code:
Code:
        ORG  $2400
START    LDAA    #$FF
    STAA    $1004
    BRA      *

:confused:
Actually, yes, there is quite a lot missing. :p

You need to use DDRA (Data Direction Port A) to set the port's bits as inputs or outputs. It's just like TRISA in PICs, only I think it's opposite. Check this, but I remember 1=output and 0=input.

Don't forget to disable the COP (like the WDT in PICs). And set your stack pointer first thing. You can see examples of this stuff in the servo source code in the last message of the thread listed at the bottom of this message.

Do you have the Pink Book? Again, foggy memory tells me that there's a Reference Manual (the Pink Book) and a Programmer's Manual. You NEED them! Scratch around on the net and you'll find free e-versions of them. EDIT: Ah, **broken link removed**.

I have tons of HC11s and a few HC12s, but my memory is very bad on them. Haven't used a HC11 in years.
EDIT: Scratch that. Helped a guy with servo code for HC11 last year. Wrote it on my MicroStamp 11.
 
Last edited:
Actually, yes, there is quite a lot missing. :p

You need to use DDRA (Data Direction Port A) to set the port's bits as inputs or outputs. It's just like TRISA in PICs, only I think it's opposite. Check this, but I remember 1=output and 0=input.

Don't forget to disable the COP (like the WDT in PICs). And set your stack pointer first thing. You can see examples of this stuff in the servo source code in the last message of the thread listed at the bottom of this message.

Do you have the Pink Book? Again, foggy memory tells me that there's a Reference Manual (the Pink Book) and a Programmer's Manual. You NEED them! Scratch around on the net and you'll find free e-versions of them. EDIT: Ah, **broken link removed**.

I have tons of HC11s and a few HC12s, but my memory is very bad on them. Haven't used a HC11 in years.
EDIT: Scratch that. Helped a guy with servo code for HC11 last year. Wrote it on my MicroStamp 11.

I have the Peter Spasov's Microcontroller Technology book. Unfortunately, there's no proper example of creating a first program - only a lot of theories are involved.

Let me go and check the links you provided and then fix the code. Gosh, that 68HC11 is just a different world! :)
 
I have the Peter Spasov's Microcontroller Technology book. Unfortunately, there's no proper example of creating a first program - only a lot of theories are involved.

Let me go and check the links you provided and then fix the code. Gosh, that 68HC11 is just a different world! :)
Yes, but they're very nice to program in asm. You may fall in love. :p Motorola is very good.
 
Yes, but they're very nice to program in asm. You may fall in love. :p Motorola is very good.

I still can't get this thing to turn off or on whenever I like. I followed some of the initialization examples, but it wouldn't budge.

Btw, my development board is the Axiom's EVBU as recommended by Peter Spasov's book and using the AxIDE.

Here's the code:
Code:
        ORG  $2400
START    LDAA    #4
    STAA    $103F ; config
    LDS    #$00FF; stack pointer
    
    LDAA    #$FF
    STAA    $1007  ; DDRC
    LDAA    #$00
    STAA    $1003  ; PORTC
    BRA      *

Needless to say, I found PIC much easier, but with the limitation of the 'W' register. :)
 
I still can't get this thing to turn off or on whenever I like. I followed some of the initialization examples, but it wouldn't budge.

Btw, my development board is the Axiom's EVBU as recommended by Peter Spasov's book and using the AxIDE.
**broken link removed**

Here's the code:
Code:
        ORG  $2400
START    LDAA    #4
    STAA    $103F ; config
    LDS    #$00FF; stack pointer
    
    LDAA    #$FF
    STAA    $1007  ; DDRC
    LDAA    #$00
    STAA    $1003  ; PORTC
    BRA      *
You should find an include file for your MCU/board, so you can use the register names instead of numbers like $1007 and $1003. I have one for the HC11D0 that you could modify for E9 (you just have to change the numbers to suit your memory map). If you can find one ready made for your E9 setup that would be easier though.

Have you looked at the memory map for your board? There's lots of different HC11 versions and they can be configured by the board designer in many different ways. These differences change the way things are memory mapped drastically. Code written for my D0 model (or for my E8's) will not work without change on your E9. The memory map is laid out completely differently. Axiom seems to have no info on their site regarding tech details on their boards.

Now that you've looked at the memory map, does your register block start at $1000? Most HC11's do map it there, but it's not necessarily there. You must check. It may be elsewhere, like with my D0, which puts the reg block at $00.

I see you've placed your org at $2400. That's the first time I've seen it start there, but I don't think I ever used a E9. Also, the board designer may have placed it there for a reason. Program memory typically starts at $b600, but I've seen $8000 used too.

Another thing to check is whether your interrupt and reset vectors are set. Especially the reset vector. I have this at the bottom of my D0 servo code:
Code:
*  Interrupt and reset vectors.
		org	$FFD6
SCI_VECT	fdb	start		;ffd6
SPI_VECT	fdb	start		;ffd8
PAI_VECT	fdb	start		;ffda
PAO_VECT	fdb	start		;ffdc
TOF_VECT	fdb	isr		;ffde

TOC5_VECT	fdb	start		;ffe0
TOC4_VECT	fdb	start		;ffe2
TOC3_VECT	fdb	start		;ffe4
TOC2_VECT	fdb	isr		;ffe6
TOC1_VECT	fdb	start		;ffe8
TIC3_VECT	fdb	start		;ffea
TIC2_VECT	fdb	start		;ffec
TIC1_VECT	fdb	start		;ffee

RTI_VECT	fdb	start		;fff0
IRQ_VECT	fdb	start		;fff2
XIRQ_VECT	fdb	start		;fff4
SWI_VECT	fdb	start		;fff6
TRAP_VECT	fdb	start		;fff8
COP_FAIL_VECT	fdb	start		;fffa
COP_CMF_VECT	fdb	start		;fffc
RESET_VECT	fdb	start		;fffe
I think all you really need at this point is the reset vector define. My memory is really foggy on this stuff though. Without it your chip may jump to some random location on reset. And yours may be different from mine because of the memory map thing, so check the details before going ahead.

Needless to say, I found PIC much easier, but with the limitation of the 'W' register. :)
Depends on what you start out with. If you started out with PICs they seem easy. If you started out on Moto and moved to PIC, you'd find PICs very strange. I did. Once you're used to them they're quite comfy though. :p

Buy me an EVBU board and I'll teach ya how! :D:D:D Just joking. :p
 
Last edited:
Yes, it's that casual EVBU recommended by the book. I thought of buying the EVBPlus by Wytec but it's difficult to order online, so I purchased the Axiom from Farnell with student discounts. :)

I've got it running though, but it's not sourcing the current to the LED, it's sinking it instead. Unlike PIC, I can source the current easily, and it makes the '1' and the '0' very clear (1 = on, 0 = off), but the 68HC11 has a different way of doing that, especially when managing ports.

The DDR registers show that '1' is an output and '0' is an input, and the PORT registers show that '0' allows to sink the +5V into the pin, and '1' is to source it out of the pin.

However, I can't declare variables like PIC's famous 'cblock... endc' thingy. And that is the huge problem since I want to make a delay subroutine (the basic decfsz for PIC), and there's no suitable 'declaration' for me to 'decrement' the register.

All I see is 'decrement accumulators' - no decrement file register.

But anyway I begin to get the hang out of playing with the 68HC11. It's a special species, and I can't just dismiss it because it's old. I need to learn this for my college, and also a hobby. :)
 
Hey, the HC11!

I used to love that thing. You could download code directly into it through the serial port, the assembler was a lot easier to read than the PIC, that segmented-capacitor ADC could do some interesting tricks the PIC can't do. One of the coolest things about it was that the interrupt sources each had their own vector, so you didn't waste machine cycles figuring out which routine it was suppose to go to.

Could this be an electrical problem? Are the anodes of the LED's connected to the same supply driving the micro? The HC11 had body-drain diodes on the port pins, if the anodes of the LED's are at a higher voltage, or off a different supply and there's some ground-loop problem you could get a current path to Vcc through those diodes.
 
E clock

Hi , i am also using CME11E9-EVBU , in single chip mode .
I wrote a code for a delay of 30sec but i measured time when hc11 would dec port b after the said delay , it turns out to be 8.8sec .

After calculating cycles in my loop i am not running my code at 0.5usec each cycle ???

on the board i can see its a 8mhz crystal , so E clock should be 2mhz .

Any ideas ???
 
Status
Not open for further replies.

Latest threads

Back
Top