📄 printer.mac
字号:
$nolist
;*******************************************************************************
;*******************************************************************************
;* *
;* (C)Copyright, CLOVER China Electronics Co.,LTD. *
;* All Rigits Reserved *
;* add:No.58-F Yang Dong Road, LuoFeng Demonstrative Zone Suzhou, China *
;* Tel: 0512-67261886 Fax:0512-67261882 *
;* http://www.clover.co.jp *
;* *
;*******************************************************************************
;*******************************************************************************
;
; LCD+thermal printer models source program
; CPU: TOSHIBA TLC-870/C series TMP86CM74A
; RAM: 2Kbytes(0040h - 083Fh)
; ROM: 24Kbytes(a000h - FFFFh)
;
;Printer controler
?trigger(@)
@include "macro.inc"
@include "symdef_ram.inc"
@include "define.inc"
$list
extern dbr_disp_clear,bl_off,bl_on,font_data,font_bnum,font_snum,tempdbr_to_dbr
public tm1_int,tm2_int,prn_init,print,key_feed,sio_int
extern vft_disable,vft_enable
extern STB_V,STB_R,STB_C,STB_E,STB
ROM section code
STP_RUSH equ 20000*2 ;20ms for rush control (1/32fc[0.5us]clock)
;STP_WKUP_LTP equ (4393-60)*2 ;4393us for wake up rush control (1/32fc[0.5us]clock)
; STP_WKUP_LTP equ 4393*2*10/5-60*2 ;25mm/s
STP_WKUP_LTP equ 4393*2*5/3-60*2 ;30mm/s
; STP_WKUP_LTP equ 4393*2*10/7-60*2 ;35mm/s
; STP_WKUP_LTP equ 4393*2*5/4-60*2 ;40mm/s
;STP_STOP_LTP equ 65000/16 ;65ms for rush control (1/128fc[16us]clock)
; STP_STOP_LTP equ 65000/16*10/5 ;25mm/s
STP_STOP_LTP equ 65000/16*5/3 ;30mm/s
; STP_STOP_LTP equ 65000/16*10/7 ;35mm/s
; STP_STOP_LTP equ 65000/16*5/3 ;40mm/s
STP_INIT equ 6579*2 ;6.579ms for initialize step (1/32fc[0.5us]clock)
STP_SLOW equ (2400-50)*2 ;2.400ms for slow up step (1/32fc[0.5us]clock)
STP_PSLOW equ (2400-100)*2 ;2.400ms for slow up step (1/32fc[0.5us]clock) for printing
STP_FEED equ (2083-100)*2 ;2.083ms for feed (1/32fc[0.5us]clock)
STP_FEED_LTP equ 5000*2 ;5ms for feed (1/32fc[0.5us]clock) for LTP8235
; STP_FEED_LTP equ 5000*2*10/5 ;25mm/s
; STP_FEED_LTP equ 5000*2*5/3 ;30mm/s
; STP_FEED_LTP equ 5000*2*10/7 ;35mm/s
; STP_FEED_LTP equ 5000*2*5/4 ;40mm/s
STP_NORM equ (1667-120)*2 ;1.667ms for normal print (1/32fc[0.5us]clock)
;STP_NORM_LTP equ (1667*2-180*2) ;50mm/S ;1.667ms for normal print (1/32fc[0.5us]clock)
; STP_NORM_LTP equ (1667*2*10/5-180*2) ;25mm/s
STP_NORM_LTP equ (1667*2*5/3-180*2) ;30mm/s
; STP_NORM_LTP equ (1667*2*10/7-180*2) ;35mm/s
; STP_NORM_LTP equ (1667*2*5/4-180*2) ;40mm/s
STP_NORM_ADJ equ 180*2 ;for calculation for parameater "C" LTP8235 printer
STP_CPON equ (300-50)*2 ;300us for chopping on (1/32fc[0.5us]clock)
STP_CPOF equ (50-20)*2 ;50us for chopping on (1/32fc[0.5us]clock)
STP_SLOW_CMP equ 2400*2 ;compare with T1 value
L_FEED equ 6
L_FEED_LTP equ 8
LARGE_FEED equ 18 ;V4.03
;==============================================
;1667*10/5=3334;1667*5/3=2778;1667*5/3.5=2381; 1667*5/4=2083
;
ltp_acc_tbl:
dw 0x0000 ;0 dummy
;for printing speed 25mm/s
; dw (4393-60)*2 ;25mm/s;equ (4393-60)*2
; dw STP_NORM_LTP ;25mm/s;equ (1667*2*10/2-180*2)
; dw STP_NORM_LTP ;25mm/s;equ (1667*2*10/2-180*2)
; dw STP_NORM_LTP ;25mm/s;equ (1667*2*10/2-180*2)
;for printing speed 30mm/s
dw (4393-60)*2 ;30mm/s;equ (4393-60)*2
dw STP_NORM_LTP ;30mm/s;equ (1667*2*5/3-180*2)
dw STP_NORM_LTP ;30mm/s;equ (1667*2*5/3-180*2)
dw STP_NORM_LTP ;30mm/s;equ (1667*2*5/3-180*2)
;for printing speed 35mm/s
; dw (4393-60)*2 ;35mm/s;1
; dw (2715-180)*2 ;35mm/s;2
; dw STP_NORM_LTP ;35mm/s;equ (1667*2*5/3.5-180*2)
; dw STP_NORM_LTP ;35mm/s;equ (1667*2*5/3.5-180*2)
;for printing speed 40mm/s
; dw (4393-60)*2 ;40mm/s;1
; dw (2715-180)*2 ;40mm/s;2
; dw (2097-180)*2 ;40mm/s;3
; dw STP_NORM_LTP ;40mm/s;equ (1667*2*5/4-180*2)
;for printing speed 50mm/s
; dw (4393-60)*2 ;50mm/s;1
; dw (2715-180)*2 ;50mm/s;2
; dw (2097-180)*2 ;50mm/s;3
; dw (1760-180)*2 ;50mm/s;4
;==============================================================================
; Timer 1 reset and start (for make strobe pulse)
;==============================================================================
@define(T1_START)(
; ld (TC1CR),0y01001000 ;TC1S(00):stop TC1CK(10)=fc/2^3 TC1M(00):timer mode (0.5us under 16M clock)
ld (TC1CR),0y00001000 ;TC1S(00):stop TC1CK(10)=fc/2^3 TC1M(00):timer mode (0.5us under 16M clock)
clr (ILL).IL5 ;clear TC1 request (ILH:bit0)
set (EIRL).EF5 ;set TC1 enable (EIRH:bit0)
; ld (TC1CR),0y01011000 ;TC1S(01):start TC1CK(10)=fc/2^3 TC1M(00):timer mode (0.5us under 16M clock)
ld (TC1CR),0y00011000 ;TC1S(01):start TC1CK(10)=fc/2^3 TC1M(00):timer mode (0.5us under 16M clock)
)
;==============================================================================
; Timer 1 stop
;==============================================================================
@define(T1_STOP)(
; ld (TC1CR),0y01001000 ;TC1S:stop
ld (TC1CR),0y00001000 ;TC1S:stop
clr (EIRL).EF5 ;clear TC1 enable (EIRH:bit0)
)
;==============================================================================
; Timer1 value set reg.wa -> TREG1AL,TREG1AM
;==============================================================================
@define(T1_SET)(
shlca wa ;x2 for 16M version
ld (TC1DRAL),wa ;set TC1DRA
)
;==============================================================================
; Timer 2 start 0.5us clock [1/32fc] (for MT step pulse [chopping]) 16M clock
;==============================================================================
@define(T2_START)(
ld (TC2CR),0y00001110 ;TC2CK(011)=fc/2^3 TC2S(0):stop TC2M(0):timer mode
clr (ILH).IL13 ;clear TC6 request (ILH:bit4)
set (EIRH).EF13 ;set TC6 enable (EIRH:bit4)
ld (TC2CR),0y00101110 ;TC2CK(011)=fc/2^3 0.5us TC2S(1):start TC2M(0):timer mode
)
;==============================================================================
; Timer 2 start 16us clock [1/128fc] (for MT step pulse [chopping]) 16M clock
;==============================================================================
@define(T2_START16)(
ld (TC2CR),0y00001010 ;TC2CK(010)=fc/2^8 TC2S(0):stop TC2M(0):timer mode
clr (ILH).IL13 ;clear TC6 request (ILH:bit4)
set (EIRH).EF13 ;set TC2 enable (EIRH:bit4)
ld (TC2CR),0y00101010 ;TC2CK(010)=fc/2^8 16us TC2S(1):start TC2M(0):timer mode
)
;==============================================================================
; Timer 2 value set (for MT step pulse,chopping)
;==============================================================================
@define(T2_SET(value))(
ldw (TC2DRL),@value ;set TC2DR
)
;==============================================================================
; Timer 2 stop (for MT step pulse chopping)
;==============================================================================
@define(T2_STOP)(
ld (TC2CR),0y00001110 ;TC2CK(011)=fc/2^3 TC2S(0):stop TC2M(0):timer mode
clr (EIRH).EF13 ;clear TC2 enable (EIRH:bit4)
)
;==============================================================================
; AD set and start (AIN6: head temp.)
;==============================================================================
@define(AD_TEMP)(
and (P4DR),0y11111100 ;AIN1,AIN0 must set '0' for AD convert
ld (ADCCR1),0y00100000 ;AD conv. stop s/w start AIN enable select AIN0(P40)
ld (ADCCR2),0y00011000 ;Rudder connect when AD convert only, ACK=312/fc (19.5us convert time 16MHz)
set (ADCCR1).7 ;AD convert start
)
;==============================================================================
; AD set and start (AIN7: VPR volt.)
;==============================================================================
@define(AD_VPR)(
and (P4DR),0y11111100 ;AIN1,AIN0 must set '0' for AD convert
ld (ADCCR1),0y00100001 ;AD conv. stop s/w start AIN enable select AIN1(P41)
ld (ADCCR2),0y00011000 ;Rudder connect when AD convert only, ACK=312/fc (19.5us convert time 16MHz)
set (ADCCR1).7 ;AD convert start
)
;==============================================================================
; Get AD convert value
;==============================================================================
@define(GET_AD)
local loop(
@loop:
ld cf,(ADCDR2).5 ;EOCF=1?
j cc,@loop
ld a,(ADCDR1) ;get AD convert value
)
;==============================================================================
; VPR on
;==============================================================================
@define(VPR_ON)(
and (P4DR),0y11111100 ;AIN1,AIN0 must set '0' for AD convert
or (P4DR),0y00000100 ;P42 set'1'(VPR)
set (F_PCONT+2).6 ;IO_MT equ (F_PCONT+2<<4)+6
)
;==============================================================================
; VPR off
;==============================================================================
@define(VPR_OFF)(
and (P4DR),0y11111000 ;AIN1,AIN0 must set '0' for AD convert, P42(VPR) set'0'
clr (F_PCONT+2).6 ;IO_MT equ (F_PCONT+2<<4)+6
)
;==============================================================================
; STB1 on
;==============================================================================
@define(STB1_TRG)(
clr (P0DR).3
)
;==============================================================================
; STB2 on
;==============================================================================
@define(STB2_TRG)(
clr (P0DR).2
)
;==============================================================================
; STB1 off
;==============================================================================
@define(STB1_OFF)(
set (P0DR).3
)
;==============================================================================
; STB2 off
;==============================================================================
@define(STB2_OFF)(
set (P0DR).2
)
;==============================================================================
; check whether STB2 off (=1?)
;==============================================================================
@define(CHK_STB2_OFF(label))(
ld cf,(P0DR).2
j cs,@label ;if bit is '1' then jump
)
;==============================================================================
; MT driver enable
;==============================================================================
@define(PHASE_ON)(
and (P4DR),0y11111100 ;AIN1,AIN0 must set '0' for AD convert
or (P4DR),0y00011000 ;P44P43 set '1'(ENA1,ENA2)
)
;==============================================================================
; MT driver disable
;==============================================================================
@define(PHASE_OFF)(
and (P4DR),0y11100100 ;AIN1,AIN0 must set '0' for AD convert,P44P43 set '0'(ENA1,ENA2)
)
;==============================================================================
; Latch enable
;==============================================================================
@define(LATCH)(
clr (P0DR).4
nop
set (P0DR).4
)
;==============================================================================
; SIO initialize
;==============================================================================
@define(INIT_SIO)(
and (P1DR),0y10111111
nop
or (P1DR),0y11000000 ;P17(CK: Hi-z), P16(EEIN: Hi-z)
ld (SIOCR1),0y01001100 ;SIOS=0, SIOINH=1 to abort and initial "SIOSR", SIOM=00(8bit Tx),SIODIR=1 LSB, SCK=fc/2^4
ld (SIOCR2),0y00000000
)
;==============================================================================
; SIO transmit start
;==============================================================================
@define(START_SIO)(
ld (SIOCR1),0y10001100 ;SIOS=1 SIOINH=0 SIOM=00(8bit Tx) SIODIR=1 SCK=fc/2^4
)
;==============================================================================
; SIO disable
;==============================================================================
@define(DIS_SIO)(
ld (SIOCR1),0y00001100 ;SIOS=0, SIOINH=1 to abort and initial "SIOSR", SIOM=00(8bit Tx) SCK=fc/2^4
or (P1DR),0y11000000 ;P17(CK: Hi-z), P16(EEIN: Hi-z)
)
;-----------------------------------------------
; Printer Initial
;-----------------------------------------------
prn_init:
ld (F_PCONT),0y00000000 ;control flags clear
ld (F_PCONT+1),0y00000000 ;control flags clear
;V4.14 ld (F_PCONT+2),0y00000000 ;control flags clear
and (F_PCONT+2),0y00100000 ;V4.14;keep P_RED flag
ld (PHASE_CT),0
ld (STEP_CT),0
@SEB (F_INIT)
@STB1_OFF
@STB2_OFF
@VPR_ON
@SEB (P_MOVE) ;under printer moving
call vft_disable
call start_up ;MT driver enable, motor start, dbr clear BL off
@BBC (SW_LTP,prn_ini_09) ;LTP8235 printer? yes->
@SEB (F_RVSE) ;reverse feed flag
prn_ini_09:
@BBS (F_INIT,prn_ini_09)
ret
;
;-----------------------------------------------------------------------------------
; 10 dotline feed
key_feed:
call print_int_check ;V4.14
key_feed_0: ;V4.14
@BBS (F_PRINT,key_feed_0)
key_feed_start:
@SEB (F_FDREQ)
@BBS (F_FEED,key_f100) ;under feed? yes->
ld (STEP_CT),0
@SEB (F_FEED)
@CLB (F_RVREQ)
@BBC (F_RUSH,key_f011) ;under rush step?(already motor stop) no-->
@CLB (F_RUSH) ;cancel rush step
j key_f100
key_f011:
call start_up ;MT driver enable, motor start, dbr clear BL off
key_f100:
@BBS (F_FDREQ,key_f100) ;
ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -