EE 308 - LAB 13

Test of Memory and Port Expansion

Now that you have completed your wiring, you will test your work.

1.
Before adding chips to your board, check (and record) the resistance between VCC and GND. It should be at least one k$\Omega$. If it is not this high, you have a mistake in your wiring.

2.
Before adding chips to your board, use a logic probe to check for power and ground. Connect your board to a 5 V supply. Make sure that the HC12 still works - i.e., make sure you get a DBug-12 prompt. With a logic probe, check for a logic high at every pin which is supposed to be wired to VCC, and for a logic low at every pin which is supposed to be wired to GND. This will insure that you did not wire your power supplies backwards; such backwards wiring could destroy all your ICs.

3.
Program your Altera chip to act as the address demultiplexer and decoder, and to supply your two new eight-bit I/O ports. To program your Altera chip use the template memexp.tdf.

There are a few changes you will need to make to the template to get the program to work. The lines you will need to change start with a **. (Be sure to take out the ** after modifying the lines.) One important consideration in making these changes is understanding when the HC12 will access even addresses and when it will access odd addresses. The following table (modified from Table 13 of the MC68HC912B32 Technical Summary) may help you.

$\overline{\tt {LSTRB}}$ A0 Type of Access
0 0 16-bit access of even address
Access data at even address 0xXXXX and
at odd address 0xXXXX+1
0 1 8-bit access of odd address 0xXXXX
1 0 8-bit access of even address 0xXXXX
1 1 16-bit access of odd address
Not used for external addressing

Note that if A0 = 0, the HC12 will access the even memory location at 0xXXXX. If $\overline{\tt {LSTRB}}$ = 0, the HC12 will access an odd memory location. When accessing odd addresses, if address 0xXXXX is even, the HC12 accesses odd address 0xXXXX+1 as well as the even address 0xXXXX; if address 0xXXXX is odd, the HC12 accesses only the odd address 0xXXXX.

When programming the Altera chip it is important to make sure the pins assigned by the Altera compiler match your wiring. If you put the file memexp.acf into the same directory as your memexp.tdf, the Altera compiler will take pin assignments from the memexp.acf file. Alternatively, you can go to the Assign Pins sub-menu of the Assign menu, and individually tell Altera which function to assign to which pin.

4.
Turn off power, put in your Alter chip and the two memory chips, and turn power back on. Use a voltmeter to check your power supply voltage. If it is not 5 V, turn power off immediately - you have a problem in your wiring.

5.
Connect Port A to the LEDs on your breadboard, and make sure you can manipulate each bit of Port A individually. It is easy to do this in DBug-12 - you do not need to write a program to do this.

6.
Repeat the above part with Port B.

7.
Go into DBug-12 and type in the following program at address 0x0D00. Do not type in the comments preceded by a semicolon after the instructions; these are for your information only.

>asm $0D00
     LDS   #$0C00      ; Load DBug-12 stack pointer
     CLR   $0016       ; Disable COP 
     LDX   #$0A00      ; Clear out DBug12 RAM
     CLR   1,X+        
     CPX   #$0C00      
     BNE   $0D09       
     LDAA  #$2C        ; Enable LSTRB and R/W
     STAA  $000A       
     BSET  $000B,#$68  ; Expanded wide mode, turn on internal visibility
     BCLR  $0013,#$08  ; Put in one E-Clock stretch
     JMP   $F717       ; Jump to DBug-12

Put your jumper onto the EXP_EN header on your board. Move jumper W3 on your EVB to postion 1 (jump to EEPROM mode). Push the reset button on your HC12. Your HC12 will execute the above code, which will put it into expanded wide mode.

8.
Fill all of the expanded memory with 0xAAs, then with 0x55s. (Use the BF command of DBug-12.) If this works, then your memory is probably wired correctly.

9.
Connect wires from Expanded Port A (from now on called Port EA) to the LEDs on your breadboard. Set up Port EA for output by setting bit 0 of address 0x402. To do this, do the following in DBug-12: Change the value of address 0x0402 to 0x01, Then use Port EA to turn on and off the LEDs on the breadboard. Do this in DBug-12 by changing the value of address 0x0400.

10.
Check out your expanded Port B (Port EB) in the same way. To make Port EB an output, set bit 4 of address 0x0402. You should be able to use Port EB to turn on and off LEDs by writing to address 0x0401.

11.
Check to make sure that Port EA works for input.

12.
If all of the above works, your board is wired correctly, and you now have 32 kbytes of RAM and two new ports. Congratulations!!!

Bill Rison, <rison@ee.nmt.edu >
Mon Apr 19 1999

© 1999, New Mexico Tech