;*************************************************************** title "PIC Sample code: PIC16F628 program" subtitle "Version 1.0 (c) Jay.slovak" ; david van brink, more, 2013-06-18, Herb is Dead ;Designed for 16F628 @4Mhz ;*************************************************************** list p=16F628 #include #include "macross.inc" __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_OFF &_INTRC_OSC_NOCLKOUT & _MCLRE_OFF & _LVP_OFF ERRORLEVEL -302 ;*************************************************************** CBLOCK 2Ah z0 z1 k0,k1,k2,k3 t0,t1 portAShadow portBShadow ENDC ;*************************************************************** org 0x0000 goto INIT NOP NOP NOP NOP NOP NOP #include "bitsets.inc" ; Put character in file characterF at position, 0 is leftmost CHARPC MACRO positionF,characterF MOVFW characterF IORLW 0x80 PUTB BCPA6 BCPA7 IFBC positionF,0 BSPA6 IFBC positionF,1 BSPA7 ; now, lower and raise one of the three WR's BAC IFBS positionF,2 ; "1" == A GOTO doA IFBS positionF,3 ; "2" == C GOTO doC GOTO doB doA: BCPB7 ;WR'A BSPB7 GOTO did doB: BCPA3 ;WR'B BSPA3 GOTO did doC: BCPA4 ;WR'C BSPA4 did: PUTLB 0x80 ENDM BASIS EQU 26 CHAR1 EQU 'A' INCK: INCF k0,f MOVFW k0 XORLW BASIS IFNZ goto INCK_done CLRF k0 INCF k1,f MOVFW k1 XORLW BASIS IFNZ goto INCK_done CLRF k1 INCF k2,f MOVFW k2 XORLW BASIS IFNZ goto INCK_done CLRF k2 INCF k3,f MOVFW k3 XORLW BASIS IFNZ goto INCK_done CLRF k3 INCK_done: RETURN DELAY: MOVLF 0x3f,z1 DELAYx: NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP DECFSZ z0,f GOTO DELAYx DECFSZ z1,f GOTO DELAYx RETURN INIT: CLRF k0 CLRF k1 CLRF k2 CLRF k3 MOVLW H'07' MOVWF CMCON CLRF PORTA CLRF PORTB CLRF portAShadow CLRF portBShadow BSF STATUS,RP0 ;Select Bank 1 CLRF TRISA ;Port A is output CLRF TRISB ;Port B is output BCF STATUS,RP0 ;Select Bank 0 Start: GOTO Pattern2 DataTable: dt " HOW WAS THE PACING A)TOO SLOW B)JUST RIGHT C)TOO FA" dt "ST? HOW MANY GODS DID YOU HAVE ZERO ONE (INCL TRINITY) MORE" dt " THAN ONE? WAS THE TEMPERATURE A)TOO HOT B)TOO COLD? " dt "WERE THE CHAIRS COMFORTABLE? " local ch = 32 while ch < 96 RETLW ch ch += 1 endw ; "012345679012345678901234567890123456789012345678901234567890123" ; "0 1 2 3 4 5 6 dt " JOY TO THE WORLD, OK? SCROLLING 12345 " dt "HELLO " ; Create a set of RETLW instructions dt "WORLD!" ; ..for each character dt .0 ; And an end marker GetCharAt: ADDLW DataTable MOVWF t0 MOVLW (DataTable >> 8) BTFSC STATUS,C ADDLW 1 MOVWF PCLATH MOVFW t0 MOVWF PCL Pattern2: PUTLA 0x18 PUTLB 0x80 CLRF k0 p2loopA: CLRF k1 CALL DELAY p2loop: MOVFW k0 ADDWF k1,W CALL GetCharAt MOVWF t1 CHARPC k1,t1 ; character t1 at position k1 INCF k1 MOVFW k1 SUBLW 12 IFNZ GOTO p2loop INCF k0 MOVFW k0 ; ANDLW 127 MOVWF k0 GOTO p2loopA END