A simple MC68CH11 program

Design a microprocessor based system that calculates the number of people entering a premise using a motion sensor. The output would be connected to two seven segment display which displays the number of people entering the premise. The display would display up to number 10 after which the number would reset to zero.

Introduction:
In this project assignment I used the THRSim11. THRSim11 is a Windows-based simulator that lets you edit, assemble, simulate, and debug programs for the Motorola 68HC11 microcontroller. THRSim11 simulates the CPU, ROM, RAM, and all memory-mapped I/O ports, and on board peripherals, such as the timer (including pulse accumulator), analog-to-digital (A/D) converter, parallel port, serial port, and I/O pins (analog and interrupts). Furthermore, a number of simulated external components can be connected to the pins of the simulated 68HC11 while debugging, including LEDs, switches, analog sliders (with variable voltage potential), and serial transmitters/receivers. There is also a 4x20 LCD character display mapped in the address space of the 68HC11.  THRSim11's user interface lets you view and control every register (CPU registers and I/O registers), memory location (data, program, and stack), and pin of the simulated microcontroller while debugging. You can also stop the simulation at any combination of events.

Flow Chart:
Input à Motion sensor à Count à Microprocessor à Counter modulo 11 program à Output à Seven segment display

Project Scope:
i.              Count pulse of motion sensor at input.
ii.            A modulo-10 counter is used as it will reset after 10 people entered the premises.
iii.           To display two BCD numbers (count up to 10) means we need to use two 7-segment displays. 

Code:


*MC68HC11
*Port E for motion sensor
*Port B for Byte 7 segment display
*by fareed jamaluddin
*KEW070017

            org       $C000 
PORTB           EQU    $1004

* Initialize

MAIN   clra     
            staa PORTB
           
*  Loop to count passenger          

SCAN ldab     $100a    ;read input at Port E (A/D converters, a motion sensor in our case)
            andb    #$01     ;mask off 7 msbs
            beq      SCAN     ;If no person walk in, keep scanning.
            adda    #$01     ;person detected start count
        ldab    #$11
        cba          #11
        beq          MAIN   ;If ten person walk in then reset counter.
            clrb 
            daa                   ;adjust for bcd           
            staa     PORTB    ;display to Dual or Byte 7-segment display
            jmp      SCAN     ;loop



Tags:
MC6800
MC68HC11
Microprocessor
Microcontroller
Assembly
Lab  experiment
Design example

No comments:

Post a Comment

readers