;* initializes timer1 for generating baud rate for the * ;* serial port, needed for midi * ;* prd_h,prd_l,sigpw,sens_tm * ;* calculates counter rate, needed for * ;* keeping sensctrl alternating high or low, * ;* using timer0 with an interrupt service * ;* routine. Stores the calc. values in * ;*
mov OP_2,#((sens_tm*256)/100) / 256 ;MSB sens_tm mov OP_3,#((sens_tm*256)/100) and 255 ;LSB sens_tm mov R2,hi_TH0 ;MSB hi_tmr0 mov R3,hi_TL0 ;LSB hi_tmr0 acall Mul_16 mov hivdTH0,OP_1 ;MSB of result, which is factor 256 too hi mov hivdTL0,OP_2 ;LSB of result, so just shift byte mov wndwTH0,OP_1 ;MSB function convert uses the max. size mov wndwTL0,OP_2 ;LSB pop hi_TH0 ;calculate hi_tmr0 = hi_tmr0 - hivdtmr0 pop hi_TL0 clr C mov A,hi_TL0 ;hi_TL0 - hivdTL0 subb A,hivdTL0 mov hi_TL0,A mov A,hi_TH0 ;borrow in MSB? subb A,hivdTH0 mov hi_TH0,A jnc ca_corl ;no borrow, so result still pos. mov hi_TL0,#001 ;timing is too short, so take minimum mov hi_TH0,#000 ;value, and store temp. in hi_t0 ca_corl: clr C ;timing correction for lo_tmr0 mov A,lo_TL0 ;lo_TL0 - proc_tm subb A,#proc_tm mov lo_TL0,A mov A,lo_TH0 ;borrow in MSB? subb A,#000 mov lo_TH0,A jnc ca_crh ;no borrow, so result still pos. mov lo_TL0,#001 ;timing is too short, so take minimum mov lo_TH0,#000 ;value, and store temp. in lo_t0 ca_crh: clr C ;timing correction for hi_tmr0 mov A,hi_TL0 ;hi_TL0 - proc_tm subb A,#proc_tm mov hi_TL0,A mov A,hi_TH0 ;borrow in MSB? subb A,#000 mov hi_TH0,A jnc ca_crhv ;no borrow, so result still pos. mov hi_TL0,#001 ;timing is too short, so take minimum mov hi_TH0,#000 ;value, and store temp. in hi_t0 ca_crhv: clr C ;timing correction for hivdtmr0 mov A,hivdTL0 ;hivdTL0 - proc_tm subb A,#proc_tm mov hivdTL0,A mov A,hivdTH0 ;borrow in MSB? subb A,#000 mov hivdTH0,A jnc ca_conv ;no borrow, so result still pos. mov hivdTL0,#001 ;timing is too short, so take minimum mov hivdTH0,#000 ;value, and store temp. in hivdt0 ca_conv: clr A ;convert timer0 clk cycles to load values. mov B,A ;So do substraction 0-lo_t0 clr C ;for lo_t0 subb A,lo_TL0 mov lo_TL0,A mov A,B subb A,lo_TH0 mov lo_TH0,A clr C ;and same for hi_t0 mov A,B subb A,hi_TL0 mov hi_TL0,A mov A,B subb A,hi_TH0 mov hi_TH0,A clr C ;and same for hivdtmr0 mov A,B subb A,hivdTL0 57