液晶电视
;******************************************************************************* ;* Function: max6951_init ;* ;* Sets the correct SPI modes for talking to the MAX6951, enables SPI, and ;* ;* initializes the MAX6951 to display 8 0s. ;* ;* Input: None. ;* ;* Output: None. ;* ;* Destroys: ACC, A[0] -- A[10], PSF ;* ;******************************************************************************* MAX6951_INIT: ; SET SPI BAUD RATE MOVE A[0], #2400H ; SYSTEM CLOCK IS 16,000,000 HZ MOVE A[1], #00F4H MOVE A[2], #4240H ; DESIRED BAUD RATE IS 1,000,000 HZ MOVE A[3], #000FH CALL SPI_SETBAUDRATE ; SET THE APPROPRIATE MODES FOR THE 6951 MOVE C, #SPI_IDLE_LOW ; IDLE = LOW CALL SPI_SETCLOCKPOLARITY MOVE C, #SPI_ACTIVE_EDGE ; ACTIVE = RISING EDGE CALL SPI_SETCLOCKPHASE MOVE C, #SPI_LENGTH_16 ; ALWAYS TRANSFER 16 BITS CALL SPI_SETCHARACTERLENGTH MOVE C, #SPI_MASTER_MODE ; MAXQ2000 IS THE MASTER, MAX6951 IS THE SLAVE CALL SPI_SETMODE ; ENABLE SPI MOVE C, #1 CALL SPI_ENABLE ; SHUTDOWN MAX6951 DISPLAY FIRST CALL MAX6951_SHUTDOWN ; SET MAX6951 IN HEXADECIMAL DECODE MODE MOVE ACC, #MAX6951REG_DECODE SLA4 SLA4 OR #0FFH ; HEXADECIMAL DECODE CALL MAX6951_TRANSMIT ; SET DISPLAY INTENSITY = 16/16 MOVE ACC, #MAX6951REG_INTENSITY SLA4 SLA4 OR #0FH ; INTENSITY = 16/16 CALL MAX6951_TRANSMIT ; SCAN LIMIT = 7 MOVE ACC, #MAX6951REG_SCANLIMIT SLA4 SLA4 OR #07H ; SCAN LIMIT = 7 CALL MAX6951_TRANSMIT RET
;******************************************************************************* ;* Function: max6951_counting ;* ;* This routine counts how many 10-milliseconds have elapsed and displays ;* ;* the value from 0000 to 9999 on LED digits 3-0(no way to blank leading digits). ;* ; The routine displays the same value on LED digits 7-4(by using no decode ;* ;* mode, individual leading digits can be blanked). ;* ;* Input: None ;* ;* Output: None ;* ;* Destroys: ACC, A[1] - A[4], A[9] ;* ;******************************************************************************* MAX6951_COUNTING: CALL MAX6951_SHUTDOWN CALL MAX6951_SET_ALL_0 ; SET ALL BITS OF DATA REGISTERS TO 0 MOVE ACC, #010FH ; HEXDECIMAL DECODE DIGITS 3-0, NO DEOCDE DIGITS 7-4 CALL MAX6951_TRANSMIT ; INITIALIZE THE COUNT TO 0 MOVE A[1], #0 ; A[1] => DIGIT 0 MOVE A[2], #0 ; A[2] => DIGIT 1 MOVE A[3], #0 ; A[3] => DIGIT 2 MOVE A[4], #0 ; A[4] => DIGIT 3 COUNT_LOOP: INCREASE_DIGIT3: MOVE ACC, A[4] ; PROCESS DIGIT 3 SUB #9 JUMP Z, INCREASE_DIGIT2 ; DIGIT 3 = 9, THERE IS CARRY OVER MOVE ACC, A[4] ; DIGIT 3 < 9, CONTINUE ADD #1 MOVE A[4], ACC CALL FONT_LOOKUP ; LOOK UP THE VALUE FOR THIS FONT ; STORE IT IN A[9], KEEP ACC UNCHANGED OR #6300H CALL MAX6951_TRANSMIT ; NO CARRY OVER, WRITE DIGIT 3 NEW VALUE MOVE ACC, A[9] ; WRITE THE NO DECODE VALUE TO DIGIT 7 OR #6700H CALL MAX6951_TRANSMIT JUMP DISPLAY_NUMBER INCREASE_DIGIT2: OR #6300H CALL MAX6951_TRANSMIT ; WRITE 0 TO DIGIT 3 REGISTER FIRST MOVE A[4], #0 ; SET DIGIT 3 BACK TO 0 MOVE ACC, #677EH ; NO DECODE VALUE FOR FONT '0' IS "7EH" CALL MAX6951_TRANSMIT ; WRITE 7EH TO DIGIT 7 REGISTER MOVE ACC, A[3] ; PROCESS DIGIT 2 SUB #9 JUMP Z, INCREASE_DIGIT1 ; DIGIT 2 = 9, THERE IS CARRY OVER MOVE ACC, A[3] ; DIGIT 2 < 9, CONTINUE ADD #1 MOVE A[3], ACC CALL FONT_LOOKUP ; LOOK UP THE VALUE FOR THIS FONT ; STORE IT IN A[9], KEEP ACC UNCHANGED OR #6200H CALL MAX6951_TRANSMIT ; NO CARRY OVER, WRITE DIGIT 2 NEW VALUE MOVE ACC, A[9] ; WRITE THE NO DECODE VALUE TO DIGIT 6 OR #6600H CALL MAX6951_TRANSMIT JUMP DISPLAY_NUMBER INCREASE_DIGIT1: OR #6200H CALL MAX6951_TRANSMIT ; WRITE 0 TO DIGIT 2 REGISTER FIRST MOVE A[3], #0 ; SET DIGIT 2 BACK TO 0 MOVE ACC, #667EH ; NO DECODE VALUE FOR FONT '0' IS "7EH" CALL MAX6951_TRANSMIT ; WRITE 7EH TO DIGIT 6 REGISTER MOVE ACC, A[2] ; PROCESS DIGIT 1 SUB #9 JUMP Z, INCREASE_DIGIT0 ; DIGIT 1 = 9, THERE IS CARRY OVER MOVE ACC, A[2] ; DIGIT 1 < 9, CONTINUE ADD #1 MOVE A[2], ACC CALL FONT_LOOKUP ; LOOK UP THE VALUE FOR THIS FONT ; STORE IT IN A[9], KEEP ACC UNCHANGED OR #6100H CALL MAX6951_TRANSMIT ; NO CARRY OVER, WRITE DIGIT 1 NEW VALUE MOVE ACC, A[9] ; WRITE THE NO DECODE VALUE TO DIGIT 5 OR #6500H CALL MAX6951_TRANSMIT JUMP DISPLAY_NUMBER INCREASE_DIGIT0: OR #6100H CALL MAX6951_TRANSMIT ; WRITE 0 TO DIGIT 1 REGISTER FIRST MOVE A[2], #0 ; SET DIGIT 1 BACK TO 0 MOVE ACC, #657EH ; NO DECODE VALUE FOR FONT '0' IS "7EH" CALL MAX6951_TRANSMIT ; WIRTE 7EH TO DIGIT 5 REGISTER MOVE ACC, A[1] ; PROCESS DIGIT 0 SUB #9 JUMP Z, COUNT_COMPLETE ; DIGIT 0 = 9, COUNTING IS OVER MOVE ACC, A[1] ; DIGIT 0 < 9, CONTINUE ADD #1 MOVE A[1], ACC CALL FONT_LOOKUP ; LOOK UP THE VALUE FOR THIS FONT ; STORE IT IN A[9], KEEP ACC UNCHANGED OR #6000H CALL MAX6951_TRANSMIT ; NO CARRY OVER, WRITE DIGIT 0 NEW VALUE MOVE ACC, A[9] ; WRITE THE NO DECODE VALUE TO DIGIT 4 OR #6400H CALL MAX6951_TRANSMIT DISPLAY_NUMBER: ; DISPLAY DIGIT 3-0 IN HEXADECIMAL DECODE MODE ; DIEPLAY DIGIT 7-4 IN NO DECODE MODE CALL MAX6951_ENABLE CALL MAX6951_10MS_DELAY JUMP COUNT_LOOP COUNT_COMPLETE: RET
全部0条评论
快来发表一下你的评论吧 !