;
;        mb_main.txt
;      
; KOTUINO mode 2     aspgm1
;
;----------------------------------------------

    .cseg at startus
  lcall  terus ;     !!!
;-------------------------
  WAITT 250
  LLPRINT str0 ;  
 wait_fl0:
  Rx_BYTE filtre0 ;     
  sjmp wait_fl0
 go_fl0:

  LLPRINT str2 ;    
 LDA_String Read_Hed
  mov dptr,#m_str1
  mov r4,#11
 loop0:
  acall bspi_rxd
  movx @dptr,a
  inc dptr
  djnz r4,loop0
  LLPRINT m_str0 ;   
   WAITT 150

  LLPRINT str3 ;  / Vpp (+12V)
 wait_fl1:
  Rx_BYTE filtre1 ;     
  sjmp wait_fl1
 go_fl1:

;       
  mov linc_port,#0xFF
  STA_cmd Oll_Pfb_on

  LLPRINT str5 ;       
           ;   "/"
 wait_fl2:
  Rx_BYTE filtre2 ;     
  sjmp wait_fl2 ;       
 go_fl2:

;    -
;   
;      
;  
;       
;(),   Vpp   
;        
;         
;    /











;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; 
  mov g_cnt,#5
 murg:
  STA_cmd Oll_Pfb_off ;  = 0
  clr linc_port.Pg_EVpp
  LLPRINT m_str2
  WAITT 200
  STA_cmd Oll_Pfb_on ;  = 1
  setb linc_port.Pg_EVpp
  LLPRINT m_str3
  WAITT 200
  djnz g_cnt,murg

 wert_p1:
  mov r6,#32
  mov tmp7,#0b10000000
 rr_fl:
  STA_buf WR_Pfb1, tmp7
  WAITT 80
  mov a,tmp7
  rr a
  mov tmp7,a
  djnz r6,rr_fl

  STA_cmd Set_Pfb1

  mov r6,#8
  mov tmp7,#0b10000000
 loop_p0:
  STA_buf Wbm0_Pfb1, tmp7
  WAITT 80
  mov a,tmp7
  rr a
  mov tmp7,a
  djnz r6,loop_p0

  mov r2,#0xFF
  STA_cmd Clr_Pfb1
 loop_p1:
  STA_cmd Inc_Pfb1
  WAITT 30
  djnz r2,loop_p1

  mov r2,#0xFF
  STA_cmd Set_Pfb1
 loop_p2:
  STA_cmd Dec_Pfb1
  WAITT 30
  djnz r2,loop_p2

  mov r2,#10
  STA_dat WR_Pfb1, 0x55
  WAITT 40
 loop_p3:
  STA_cmd Cpl_Pfb1
  WAITT 40
  djnz r2,loop_p3



 STA_cmd Set_Pfb1
  LLPRINT it_str0
 Rx_BYTE rx_test
 l_test0:
  jbc test_key,print_s
  jbc fts0,restart
  sjmp l_test0
 print_s:
  LLPRINT it_str1
  sjmp l_test0
 restart:
  LLPRINT it_str4
  WAITT 50
 ajmp wert_p1




   
   TEST_STOP


;-------------------------
; ext_testus:


 rx_test:
   setb c
   mov dptr,#it_str2
   mov a,tmp_rx
   movx @dptr,a
   anl a,#0x0F
   jz exit_test
   setb test_key
   mov r1,a
   clr a
  test0:
   rlc a
   djnz r1,test0
   mov tmp0,a
   STA_buf WR_Pfb1, tmp0
   ret
   
 exit_test:
   setb fts0
   clr REN
   ret














;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
