2012年11月28日 星期三

Mini-project: Sokoban


               On these two weeks, we need to do the mini-project. The project title is Sokoban. That means we need to write a assembly game of Sokoban. In this game,  Player pushes boxes or crates around in a warehouse, trying to get them to storage locations.
              First of all, we need to connect the graphical LCD (128X64) and 6X4 keypad to our system board.

Schematic of keypad
pin assignment of graphic LCD












Here is the result of our final circuit















Final product











           

             












             And we write a test program to test whether the LCD display is work correctly or not. And finally we found out it is work. In this wrap wire experience, I feel some trouble on testing the circuit is work or not. However, I have learnt how to use CRO to find out the problem. I use CRO to trace the signal. Finally, I found out a active low pin remains low at all time. This technique is very useful.
           Now, we still are writing our assembly game. This is a challenging project. The workload is a bit high. We have to finish this project within 3 weeks. Therefore, we need to take the extra session to do this project. Although, this project is tough, I have learnt more things from this course. 


Experiment 6 -- Interface of the 8088 MPU with the 8259A PIC and LCD Module


In this week, I have done the experiment 6. This lab is to study the interfacing of the 8259A PIC with the 8088 MPU and the interfacing of the LCD module with the 8088 MPU. I need to Wrap wire the control signals of the 8259A and LCD module as shown in the lab manual, modify the I/O address field of the given test program to match our design of address decoder. Finally I need to write my own program to fulfill the following function, the switch button is pressed, my name and ID will display on the LCD.  When the button is pressed again, my partner’s name and ID will display on the LCD.

















I need to according to the above figure to wrap wire, The typical one is pin7-14 of Character LCD are connected to AD0~AD7.  The pin 6 of character LCD is connected to GAL  pin17 which I have modified the address decoder  for selecting the character LCD.

For writing this assembly program, I need to initialize all the devices first. I write to loop function which can display the name of my partner and I sequentially.
     
loop1:
check2: call check_key1
        jnc check2
        mov      dx,lcd_base
        call TURN_LED1_ON
        call display1
        mov cx,50
        call delay_X
       
check: call check_key1
        jnc check
        mov      dx,lcd_base

        call TURN_LED2_ON    
        call display2 
        mov cx,50
        call delay_X           
jmp loop1

Also I have to write the display string function, which can display name on the LCD display.
        outs1 db 'Cheng Ka Kui',0dh
        outs2 db '1155003893',0dh
        outs3 db 'Tai Pit Tat',0dh
        outs4 db '1155023064',0dh            
                       
display1   PROC      NEAR
        mov      dx,lcd_base
busy7:     in         al,dx
        and       al,10000000b
        jnz        busy7
        mov      al,00000001b    ;clear screen
        out        dx,al
;display string1
        mov      dx,lcd_base
busy10:   in         al,dx
        and       al,10000000b
        jnz        busy10
        mov      al,10000000b    ;set display address to 0
        out        dx,al
        mov      bx, offset outs1
        call        print_string
;display string2               
        mov      dx,lcd_base
busy20:   in         al,dx
        and       al,10000000b
        jnz        busy20
        mov      al,11000000b    ;set display address to 0
        out        dx,al
        mov      bx, offset outs2
        call        print_string
        ret
display1   ENDP

display2   PROC      NEAR
        mov      dx,lcd_base
busy72:   in         al,dx
        and       al,10000000b
        jnz        busy72
        mov      al,00000001b    ;clear screen
        out        dx,al
;display string3
        mov      dx,lcd_base
busy12:   in         al,dx
        and       al,10000000b
        jnz        busy12
        mov      al,10000000b    ;set display address to 0
        out        dx,al
        mov      bx, offset outs3
        call        print_string
;display string4               
        mov      dx,lcd_base
busy22:   in         al,dx
        and       al,10000000b
        jnz        busy22
        mov      al,11000000b    ;set display address to 0
        out        dx,al
        mov      bx, offset outs4
        call        print_string
        ret
display2   ENDP

Here is the result of our lab.






















              

            
              After doing this lab, I have learnt how to write the assembly program. This is a very interesting lab. I can wrap wire to connect the device and write our own program. When the LCD can display the name and ID successfully, we felt a great sense of achievement.

2012年11月7日 星期三

Experiment 5 -- Parallel I/O and Timer/Count Interface


        On this two week, I had done the lab 5. The objective of Lab 5 is to study the interfacing of the 8255 PPI and 8254 PTC with the 8088 MPU. First of all, I need to wrap wire the control signals of the 8255 PPI and 8254 PTC as shown in the figure below.
























         This is a very interesting hand work. After that, I have to write my own assembly program for the certain result. Once the switch button is pressed, the buzzer will be activated with a 1-KHz signal for a duration of around 0.5 seconds and all LEDs are turned on. If the button is pressed again, the all LEDs are turned off.

For verifying that I had generated 1-KHz signal, I used oscilloscope to see the output signal’s frequency as the below figure.
Here is the part of assembly program which set 1 KHz signal's frequency.
  timer_1KHz_msb     equ     9
  timer_1KHz_lsb     equ     196
;When the switch is pressed, LEDs change state and sound 0.5 second.
EXAMPLE1   PROC  NEAR
      ;call  ram_test
    ; Initialize the 8255 in mode 0
    mov dx,i8255_base_address
      mov al,10010000B ;set PA as input, set PB as output, set PC as output
      inc dx
      inc dx
      inc dx                  ;point to command register
      out dx,al
       ;end initialize the 8255
       ; Initialize the 8254 in mode 3
    mov     al,00110110B
      mov     dx,i8254_base_address
      inc     dx
      inc     dx
      inc     dx       ;point to command register
      out     dx,al
      mov     dx,i8254_base_address
      mov     al,timer_1KHz_lsb
      out     dx,al
      mov     al,timer_1KHz_msb
      out     dx,al
       ;end initialize the 8254

  To calculation of the value in MSB and LSB for generating 1 KHz
We know that the period of 1 KHz signal is 1ms. The period of a 2.5MHz clock signal is 0.4us. Therefore, the number of count for the counter is 0.5ms/0.4us= 9*256+196
Thus, MSB is 9 and LSB is 196.
This is a very interesting and meaningful lab. As this lab course is related to ELEG323 0(Microprocessors and computer systems). I have to use the knowledge that I have learnt in ELEG3230 to the lab. I feel proud of me that I can apply those things into the lab.