單片機(jī)之秒表匯編程序
頻率12mhz ,從零開(kāi)始計(jì)到99秒,原理為先通過(guò)十六進(jìn)制和十進(jìn)制的轉(zhuǎn)換后使用變址尋址把數(shù)據(jù)
顯示出來(lái),十位和各位共延時(shí)4毫秒,如果有按鍵按下計(jì)數(shù)從零開(kāi)始
DIZHI EQU 21H ;用于中間的數(shù)據(jù)傳送COUNT EQU 22H ;用于計(jì)數(shù)器的自加ORG 0000HJMP STARTORG 0030HTAB: DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H ;共陽(yáng)極代碼START: CLR COUNTWORK1: CALL DISPY ;十六進(jìn)制的轉(zhuǎn)換,輸出代碼顯示INC COUNTJNB P2.0 , FUYUAN ;s4按下從零開(kāi)始計(jì)數(shù)MOV A ,COUNTCJNE A ,#100 ,WORK2CLR COUNTCALL STARTWORK2: LJMP WORK1DISPY: MOV A ,COUNTMOV B ,#10DIV ABMOV R1 ,#250 ;寄存器計(jì)數(shù)250次,一次4毫秒MOV DIZHI ,ADISP: MOV A ,DIZHI ;數(shù)據(jù)的中間交換MOV DPTR ,#TABMOVC A ,@ A+DPTR;變址尋址MOV P0 ,A ;P0為段選CLR P2.5 ;P2位選,顯示十位CALL DELSETB P2.5MOV A ,BMOVC A , @A+DPTRMOV P0 ,A ;顯示個(gè)位CLR P2.4CALL DELSETB P2.4DJNZ R1 ,DISPRETFUYUAN:CALL DELMOV P0 ,#11111111BMOV P2 ,#11111111BLJMP START ;從零開(kāi)始DEL: MOV R6 ,#4F1: MOV R7, #250 ;延時(shí)兩個(gè)毫秒F2: DJNZ R7 ,F2DJNZ R6 ,F1RETEND
模數(shù)轉(zhuǎn)換器相關(guān)文章:模數(shù)轉(zhuǎn)換器工作原理
評(píng)論