LAB 5 FOR EBOT - This stationery serves as the framework...

  • Ryerson University
  • COE 538
  • Lab Report
  • Pakistani
  • 12
  • 100% (8) 8 out of 8 people found this document helpful

This preview shows page 1 - 4 out of 12 pages.

;***************************************************************** ;* This stationery serves as the framework for a * ;* user application (single file, absolute assembly application) * ;* For a more comprehensive program that * ;* demonstrates the more advanced functionality of this * ;* processor, please see the demonstration applications * ;* located in the examples subdirectory of the * ;* Freescale CodeWarrior for the HC12 Program directory * ;***************************************************************** ; export symbols XDEF Entry, _Startup ; export 'Entry' symbol ABSENTRY Entry ; for absolute assembly: mark this as application entry point ; Include derivative-specific definitions INCLUDE 'derivative.inc' ;ROMStart EQU $4000 ; absolute address to place my code/constant data ORG $3800 ; Insert here your data definition. addata ds.b 2 ;for bcd converter use BCD_BUFFER EQU addata ;The following registers are the BCD buffer area TEN_THOUS RMB 1 ;10,000 digit THOUSANDS RMB 1 ;1,000 digit HUNDREDS RMB 1 ;100 digit TENS RMB 1 ;10 digit UNITS RMB 1 ;1 digit BCD_SPARE RMB 2 ;Extra space for decimal point and string terminator NO_BLANK RMB 1 ;Used in ’leading zero’ blanking by BCD2ASC LCD_DAT EQU PORTB ; LCD data port, bits - PS7,PS6,PS5,PS4 LCD_CNTR EQU PTJ ; LCD control port, bits - PE7(RS),PE4(E) LCD_E EQU $80 ; LCD E-signal pin LCD_RS EQU $40 ; LCD RS-signal pin START0 EQU 7 START EQU 0 FORWARD EQU 1 REVERSE EQU 2 ALL_STOP EQU 3 REVERSE_TURN EQU 4 FORWARD_TURN EQU 5 CURRENT_STATE RMB 1 FWD_INTERVAL EQU 115 ;5 second forward time T_FWD RMB 1 ;alarm time for forward motion REV_INTERVAL EQU 69 ;3 second reverse time T_REV RMB 1 ;ALARM TIME FOR REVERSE MOTION REV_TURN_INTERVAL EQU 69 ;3 SECOND REVERSE TURN TIME T_REV_TURN RMB 1 ;REVERSE_TURN ALAMRM FWD_TURN_INTERVAL EQU 69 ;3 SECOND FORWARD TURN TIME T_FWD_TURN RMB 1 ;FORWARD TURN ALARM TIME TOF_COUNTER DS.B 1 ;overflow counter SPACE FCC ' '
FCB 0 DOT FCC '.' bump_check FCB 1 ; 1 means no bumper, 2 means bumper activated ; CODE SECTION ;************************************************************************ ORG $4000 Entry: _Startup: LDS #$4000 ;initialize the stack pointer SEI JSR ENABLE_TOF CLI ;enable interrupts MOVB #$03, DDRA MOVB #$30, DDRT movb #$80,ATDCTL2 ;sets bit7 to 1 to power up movb #$0c,ATDCTL3 ;fifo on and 1 sampling movb #$8B,ATDCTL4 ;8-bit operation & PRS=11 (1Mhz cycle) LDAA #START0 STAA CURRENT_STATE loop JSR openLCD JSR READ_BATTERY JSR DISPLAY LDAA CURRENT_STATE JSR DISPATCHER BRA loop ;BATERY DISPLAY SUBROUTINES ;************************************************************************ READ_BATTERY movb #$80,ATDCTL2 ;sets bit7 to 1 to power up movb #$0c,ATDCTL3 ;fifo on and 1 sampling movb #$8B,ATDCTL4 ;8-bit operation & PRS=11 (1Mhz cycle) movb #$00,ATDCTL5 ;chanel=0,single conversion,left justified, no MULTI jsr statuscheck ;checks if it finishes reading ldaa ATDDR0 ;loads value of converted value (i.e Nad) of channel 5 jsr function ;converts to BCD RTS DISPLAY ldaa TEN_THOUS jsr putcLCD ldaa THOUSANDS jsr putcLCD ldaa DOT jsr putcLCD ldaa HUNDREDS jsr putcLCD ldx #$00 ;for while loop to display all characters ldaa SPACE LOOP1 jsr putcLCD inx
ldaa SPACE,x beq LOOPE bra LOOP1 LOOPE rts RTS ********************************************************************** * State Dispatcher * * This routine calls the appropriate state handler based on the current * state.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture