;=======SILVER1.ASM======================================================== ; radix hex ; list p=16f876 ; ; ;———————————————————————— indf equ 00 tmr0 equ 01 pcl equ 02 status equ 03 fsr equ 04 porta equ 05 portb equ 06 portc equ 07 pclath equ 0a intcon equ 0b pir1 equ 0c pir2 equ 0d ; tmr1l equ 0e tmr1h equ 0f t1con equ 10 tmr2 equ 11 t2con equ 12 sspbuf equ 13 sspcon equ 14 ccpr1l equ 15 ccpr1h equ 16 ccp1con equ 17 rcsta equ 18 txreg equ 19 rcreg equ 1a ccpr2l equ 1b ccpr2h equ 1c ccp2con equ 1d adresh equ 1e adcon0 equ 1f ; optreg equ 01 trisa equ 05 trisb equ 06 trisc equ 07 pie1 equ 0c pie2 equ 0d pcon equ 0e sspcon2 equ 11 pr2 equ 12 sspadd equ 13 sspstat equ 14 txsta equ 18 spbrg equ 19 adresl equ 1e adcon1 equ 1f ; ;————————————————————————- w equ 0 f equ 1 ; c equ 0 dc equ 1 z equ 2 pd equ 3 to equ 4 rp0 equ 5 rp1 equ 6 irp equ 7 ; ps0 equ 0 ps1 equ 1 ps2 equ 2 psa equ 3 tose equ 4 tocs equ 5 intedg equ 6 rbpu equ 7 ; rbif equ 0 intf equ 1 toif equ 2 rbie equ 3 inte equ 4 toie equ 5 peie equ 6 gie equ 7 ; tmr1ie equ 0 tmr2ie equ 1 ccp1ie equ 2 sspie equ 3 txie equ 4 rcie equ 5 adie equ 6 ; ccp2ie equ 0 bclie equ 3 eeie equ 4 tmr1if equ 0 tmr2if equ 1 ccp1if equ 2 sspif equ 3 txif equ 4 rcif equ 5 adif equ 6 ; ccp2if equ 0 bclif equ 3 eeif equ 4 ; adon equ 0 godone equ 2 chs0 equ 3 chs1 equ 4 chs2 equ 5 adcs0 equ 6 adcs1 equ 7 ; pcfg0 equ 0 pcfg1 equ 1 pcfg2 equ 2 pcfg3 equ 3 adfm equ 7 ; sspm0 equ 0 sspm1 equ 1 sspm2 equ 2 sspm3 equ 3 ckp equ 4 sspen equ 5 sspov equ 6 wcol equ 7 ; sen equ 0 rsen equ 1 pen equ 2 rcen equ 3 acken equ 4 ackdt equ 5 ackstat equ 6 gcen equ 7 ; bf equ 0 ua equ 1 r_w equ 2 s equ 3 p equ 4 d_a equ 5 cke equ 6 smp equ 7 ; ;—————————————————————————— data0 equ 0020 eeddr1 equ 0021 eeddr0 equ 0022 temp equ 0023 ; xmtreg equ 0026 cntrb equ 0027 cntra equ 0028 bitctr equ 0029 ;—————————————————————————— eeslv equ 0a0 xmit equ 06 ; OH equ 04f KAY equ 04b TEE equ 054 ESS equ 053 PEE equ 050 ee equ 065 LF equ 00a CR equ 00d ; ;——————————————————————————- org 0x00 start movlw 0ff movwf portb clrf porta bsf status,rp0 movlw 0x06 movwf adcon1 movlw 00fb movwf trisa movlw 0001 movwf trisb movlw 00bf movwf trisc movlw 0x09 movwf sspadd bcf status,rp0 bsf portc,xmit dly clrf bitctr dly0 call full decfsz bitctr,f goto dly0 ; movlw OH movwf xmtreg call asyxmtc movlw KAY movwf xmtreg call asyxmtc movlw CR movwf xmtreg call asyxmtc movlw LF movwf xmtreg call asyxmtc movlw 0028 movwf sspcon bsf status,rp0 movlw 0080 movwf sspstat movlw 0013 movwf sspadd bcf status,rp0 ; ; demo1 movlw TEE movwf data0 clrf eeddr1 movlw 018 movwf eeddr0 call swrit bsf status,rp0 btfsc sspcon2,ackstat goto errsrv bcf status,rp0 ; movlw ESS movwf data0 ; call sread bsf status,rp0 btfsc sspcon2,ackstat goto errsrv bcf status,rp0 movf data0,w movwf xmtreg call asyxmtc ; dead goto dead ; errsrv bcf status,rp0 movlw ee movwf xmtreg call asyxmtc goto dead ; sstart bcf pir1,sspif bsf status,rp0 bsf sspcon2,sen bcf status,rp0 sstart1 btfss pir1,sspif goto sstart1 return ;—————————————————————————— sstop bcf pir1,sspif bsf status,rp0 bsf sspcon2,pen bcf status,rp0 sstop1 btfss pir1,sspif goto sstop1 return ;—————————————————————————— srestrt bcf pir1,sspif bsf status,rp0 bsf sspcon2,rsen bcf status,rp0 srestr1 btfss pir1,sspif goto srestr1 return ;—————————————————————————— spre call sstart movlw eeslv movwf temp bcf temp,0 movf temp,w bcf pir1,sspif movwf sspbuf spre1 btfss pir1,sspif goto spre1 bsf status,rp0 btfsc sspcon2,ackstat goto sprex bcf status,rp0 movf eeddr1,w bcf pir1,sspif movwf sspbuf spre2 btfss pir1,sspif goto spre2 bsf status,rp0 btfsc sspcon2,ackstat goto sprex bcf status,rp0 movf eeddr0,w bcf pir1,sspif movwf sspbuf spre3 btfss pir1,sspif goto spre3 sprex bcf status,rp0 return ;—————————————————————————— swrit call spre bsf status,rp0 btfsc sspcon2,ackstat goto swrit4 bcf status,rp0 movf data0,w bcf pir1,sspif movwf sspbuf swrit1 btfss pir1,sspif goto swrit1 swrit2 bcf status,rp0 call sstop ; ; call sstart movlw eeslv movwf temp bcf temp,0 movf temp,w bcf pir1,sspif movwf sspbuf swrit3 btfss pir1,sspif goto swrit3 bsf status,rp0 btfsc sspcon2,ackstat goto swrit2 ; swrit4 bcf status,rp0 call sstop swritx return ;——————————————————————————- sread call spre bsf status,rp0 btfsc sspcon2,ackstat goto sread4 bcf status,rp0 call srestrt movlw eeslv movwf temp bsf temp,0 movf temp,w bcf pir1,sspif movwf sspbuf sread1 btfss pir1,sspif goto sread1 bsf status,rp0 btfsc sspcon2,ackstat goto sread4 bcf status,rp0 bcf pir1,sspif bsf status,rp0 bsf sspcon2,rcen bcf status,rp0 sread2 btfss pir1,sspif goto sread2 movf sspbuf,w movwf data0 bcf pir1,sspif bsf status,rp0 bsf sspcon2,ackdt bsf sspcon2,acken bcf status,rp0 sread3 btfss pir1,sspif goto sread3 sread4 bcf status,rp0 call sstop sreadx return ; asyxmtc bcf portc,xmit call full movlw 08 movwf bitctr asyxmt1 rrf xmtreg,f btfsc status,c goto asyxmt2 bcf portc,xmit goto asyxmt3 asyxmt2 bsf portc,xmit ; asyxmt3 call full decfsz bitctr,f goto asyxmt1 ; bsf portc,xmit call full retlw 0 ;——————————————————————————- full movlw d’3′ movwf cntrb vdly0 movlw d’43’ movwf cntra vdly1 decfsz cntra,f goto vdly1 decfsz cntrb,f goto vdly0 retlw 0 ;————————————————————————- end