⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 v_audi.asm

📁 读取大众车系的汽车故障码的51程序,支持BOSCH协议
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;============================================================================;
;[sys.]:da zong audi series VOLKSWAGEN/AUDI v1.0                                                  ;   
;[support hardware]:atmel mcu (89c2051--18.4320mhz)                          ;
;[name]:yong guan jiang                                                      ;
;[date]:2001-2-20                                                           ;
;[file]:c:\mds\V_AUDI.ASM                                                        ;
;============================================================================;
                  hitch           bit     00h
                  ans_ok          bit     01h
                  finish          bit     02h
                  com_error       bit     03h
                  send            bit     04h
                  recever         bit     05h
                  start_bit       bit     06h
                  end_f           bit     07h
                  over_f          bit     08h
                  off_disp        bit     09h
                  int_ex0_f       bit     0ah
            ;----------------------------------
                  led_d4          bit     p3.0
                  txd_p           bit     p3.1 
                  rxd_p           bit     p3.2  
                  led_d3          bit     p3.3 
                  led_d2          bit     P3.4 
                  led_d1          bit     p3.5 
                  l_line          bit     p3.7
            ;----------------------------------
                  t_count         equ     50h
                  int_cont        equ     51h
                  s_r_cont        equ     52h
                  s_bufer         equ     53h
                  s_data0_l       equ     54h
                  s_data0_h       equ     55h
                  s_data1_l       equ     56h
                  s_data1_h       equ     57h
                  s_data2_l       equ     58h
                  s_data2_h       equ     59h
                  th_bufer        equ     5ah
                  tl_bufer        equ     5bh
                  hitch_count     equ     5ch
                  channel         equ     5dh
                  channel_buf     equ     5eh
                  frame_cnt       equ     5fh
                  rec_cnt         equ     60h
                  dis_count       equ     61h    
                  dis_time        equ     62h
                  bufer1          equ     63h
                  bufer2          equ     64h    
                  bufer3          equ     65h    
                  bufer4          equ     66h    
                  clr_buf         equ     67h    
                  hitch_cont      equ     68h    
;================================================================
                  org   0000h
system_jump:      ajmp  start
                  org   0003h
                  ajmp  int_ex0 
                  org   000bh
                  ajmp  int_t0
                  org   001bh
                  ajmp  int_t1
;----------------------------------------------------------------
;start main program
                  org   0020h
start:            mov   sp,#6ah
                  mov   ie,#88h             ;open int,setb ea.et1
                  mov   tmod,#10h           ;tmode 2, 16 bit count
                  mov   tcon,#40h           ;setb tr1,
                  setb  px0
                  clr   pt1
                  ;
                  mov   20h,#0
                  mov   21h,#0
                  mov   22h,#0
                  clr   a
                  mov   r0,#50h
                  mov   r1,#18h
          con_clr:mov   @r0,a
                  inc   r0
                  djnz  r1,con_clr
                  ;
                  mov   a,#16h
                  mov   r1,#4
                  mov   r0,#bufer1
          con_set:mov   @r0,a
                  inc   r0
                  djnz  r1,con_set
                  ;
                  acall delay_200ms
        start_com:acall dis_launch
                  acall delay_200ms
                  acall delay_200ms
;---------------------------------------------------------------------
;start read system hitch
                  mov   clr_buf,#0
            sys_1:mov   a,clr_buf
                  cjne  a,#3,sys_1_a
                  mov   clr_buf,#0
                  ;
          sys_1_a:mov   a,#1
                  acall dis_channel
                  mov   channel,#1        ;read engine hitch
                  acall read_hitch_code
                  ;
          sys_2:  mov   a,#2
                  acall dis_channel
                  mov   channel,#2        ;read gearbox hitch
                  acall read_hitch_code
                  ;
          sys_3:  mov   a,#3
                  acall dis_channel
                  mov   channel,#83h      ;read brake hitch
                  acall read_hitch_code
                  ;
          sys_4:  mov   a,#4
                  acall dis_channel
                  mov   channel,#15h      ;read airbag hitch
                  acall read_hitch_code
                  ;
                  inc   clr_buf
                  sjmp  sys_1
;=====================================================================
int_ex0:          mov   th0,s_data1_h     ;read start bit "0"
                  mov   tl0,s_data1_l
                  setb  tr0
                  setb  et0
                  mov   th_bufer,s_data0_h
                  mov   tl_bufer,s_data0_l
                  setb  recever
                  mov   s_r_cont,#9 
                  setb  int_ex0_f
                  clr   ex0
                  reti
;---------------------------------------------------------------------
int_t0:           mov   tl0,tl_bufer      ;read data     
                  mov   th0,th_bufer           
                  push  acc                    
                  push  psw
                  mov   a,s_r_cont  
                  cjne  a,#1,int_t0_1
                  sjmp  int_t0_2
        int_t0_1: mov   a,s_bufer
                  jb    rxd_p,con_recv2        
                  clr   c                ;bit "0"      
        con_recv1:rrc   a                      
                  mov   s_bufer,a        ;s_bufer is data bufer      
        int_t0_2: djnz  s_r_cont,int_t0_e  
                  clr   recever
                  clr   et0
                  clr   tr0
       int_t0_e:  pop   psw
                  pop   acc
                  reti
        con_recv2:setb  c                 ;bit "1"     
                  sjmp  con_recv1
;---------------------------------------------------------------------
;int t1 intrupt
;the int1 program main process led display
int_t1:           mov   tl1,tl_bufer           
                  mov   th1,th_bufer       ;send byte count    
                  push  acc                    
                  push  b                      
                  push  psw
                  jnb   send,disp_led0        
                  mov   a,s_bufer          ;s_bufer is send bufer    
                  setb  c
                  rrc   a
                  mov   txd_p,c
                  mov   s_bufer,a              
                  djnz  s_r_cont,int_t1_r  ;disp_led      
                  clr   send                   
                  ajmp  disp_led0
                  ;
;--------------------------------------------------------------------
;display led
       disp_led0: mov   th1,#0fah
                  mov   tl1,#24          ;th1,tl1 is delay 1ms count
       disp_led:  setb  led_d1
                  setb  led_d2
                  setb  led_d3
                  setb  led_d4           ;close display
                  jb    off_disp,int_t1_e
                  mov   a,dis_count
                  mov   b,#4
                  mul   ab
                  mov   dptr,#dis_tab
                  jmp   @a+dptr
         dis_tab: mov   a,bufer1
                  sjmp  int_t1_0
                  mov   a,bufer2
                  sjmp  int_t1_0
                  mov   a,bufer3
                  sjmp  int_t1_0
                  mov   a,bufer4
        int_t1_0: mov   dptr,#led_dcharacter
                  movc  a,@a+dptr
                  jnb   p1.0,int_t1_a
                  setb  acc.0
        int_t1_a: mov   p1,a
                  mov   a,dis_count
                  mov   b,#4
                  mul   ab
                  mov   dptr,#dis_tab0
                  jmp   @a+dptr
         dis_tab0:clr   led_d1           ;open one unit only 
                  sjmp  int_t1_1
                  clr   led_d2
                  sjmp  int_t1_1
                  clr   led_d3
                  sjmp  int_t1_1
                  clr   led_d4
         int_t1_1:mov   a,dis_count
                  inc   a
                  mov   b,a
                  clr   c
                  subb  a,#4
                  jc    int_t1_2
                  mov   b,#0
        int_t1_2: mov   dis_count,b
        int_t1_e: inc   int_cont               
        int_t1_r: pop   psw
                  pop   b
                  pop   acc
                  reti
;=========================================================================
dis_launch:       mov   23h,#10h        ;display "LAUNCH" word
                  mov   24h,#0ah
                  mov   25h,#11h
                  mov   26h,#12h
                  mov   27h,#13h
                  mov   28h,#14h
                  ;
                  mov   r2,#10          ;move display "LAUNCH"
        dis_lach: mov   b,bufer4
                  mov   bufer4,bufer3
                  mov   bufer3,bufer2
                  mov   bufer2,bufer1
                  mov   bufer1,23h    
                  mov   23h,24h       
                  mov   24h,25h       
                  mov   25h,26h       
                  mov   26h,27h       
                  mov   27h,28h       
                  mov   28h,b
                  acall delay_200ms
                  djnz  r2,dis_lach
                  ret
;------------------------------------------------------------
dis_channel:      mov   bufer4,#14h
                  mov   bufer3,a
                  mov   bufer2,#16h
                  mov   bufer1,#16h
                  ret
;============================================================
read_hitch_code:  mov   tmod,#11h
       car_comm:  lcall send_address    ;send channel "5bps"
                  ;
    rec_55h:      mov   r4,#10          ;wait count
                  mov   int_cont,#0
                  mov   th0,#0
                  mov   tl0,#0
       rec_ti:    jb    rxd_p,cmm1
                  nop                   ;"start" bit
                  clr   tr1
                  jnb   rxd_p,$
                  setb  tr0             ;"D0" bit 
                  setb  tr1
                  jb    rxd_p,$
                  nop                   ;"D1" bit
                  jnb   rxd_p,$
                  nop                   ;"D2" bit
                  jb    rxd_p,$
                  nop                   ;"D3" bit
                  clr   tr1
                  jnb   rxd_p,$
                  clr   tr0             ;"D4" bit
                  setb  tr1
                  jb    rxd_p,$
                  nop                   ;"D5"bit
                  jnb   rxd_p,$
                  nop                   ;"D6" bit
                  jb    rxd_p,$
                  nop                   ;"D7" bit
                  jnb   rxd_p,$
                  ;                     ;"end" bit
                  lcall cal_baud        ;recever "55h" ok
                  setb  off_disp
                  ljmp  comm_ok         ;communcation ok,go to read keyword
                  ;
            cmm1: mov   a,int_cont
                  cjne  a,#200,rec_ti
                  mov   int_cont,#0
                  cpl   over_f
                  jb    over_f,cmm2
                  cpl   off_disp
            cmm2: mov   int_cont,#0
                  djnz  r4,rec_ti
                  clr   over_f
                  clr   off_disp
                  ajmp  comm_err1       ;no system jmp to error
                  ;
         comm_ok: setb  off_disp 
                  lcall recv_byte       ;read keyword1
                  jc    err_e
                  lcall recv_byte       ;read keyword2
                  jc    err_e
                  mov   t_count,#22
                  acall delay_times
                  cpl   a
                  lcall send_byte
                  sjmp  cmm4
                  ;
          err_e:  ajmp  comm_err2
                  ;
          cmm4:   lcall recv_byte
                  jc    err_e
                  cjne  a,#3,cont_r
                  setb  ans_ok
         cont_r:  mov   rec_cnt,a
                  dec   rec_cnt
                  cpl   a
                  lcall send_byte
                  lcall recv_byte
                  jc    err_e
                  mov   frame_cnt,a
                  inc   frame_cnt
         recx:    cpl   a
                  lcall send_byte
                  lcall recv_byte
                  jc    err_e
                  djnz  rec_cnt,recx
           cont_y:mov   t_count,#15
                  acall delay_times
                  jb    ans_ok,ver_ok
                  acall cont_link
                  jnc   cmm4  
                  ajmp  comm_err2
ver_ok:                                  ;send read hitch code
   read_hitch:    clr   ans_ok
                  mov   s_bufer,#3       ;send "03h"
                  lcall send_cplb
                  jnc   r_hitch_d
                  ajmp  comm_err2
        r_hitch_d:mov   a,frame_cnt      ;send "length"
                  lcall send_cplb
                  jnc   r_hitch_e
                  ajmp  comm_err2
        r_hitch_e:mov   a,#7            ;send "7h" read hitch command
                  lcall send_cplb
                  jnc   r_hitch_f
                  ajmp  comm_err2
        r_hitch_f:mov   a,#3            ;send finish byte code "03h"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -