' HC4LED.BAS ' Test Program for BAS2PIC compiler 0.30 ' Use with Microchip PICkit1 and a PIC12f675 ' Shows how to control the HC4LED display module DEVICE 12f675 ' FOLLOWING LINE IS FOR DEVICE CONFIGURATION SEE DEVICE DOCUMENATION : __CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _INTRC_OSC_NOCLKOUT & _MCLRE_OFF & _CPD_OFF PROGRAM START ' Define Pins DIM Clk AT GPIO.5 DIM Dat AT GPIO.4 ' Define Variables DIM cnt AS Byte DIM segments AS Byte DIM segmentsMSB AT segments.7 START: : BCF STATUS,RP0 ; BANK 0 : CLRF GPIO ; GPIO=%00000000 'All output off : MOVLW B'00000111' ; CMCON=%00000111 'No comparitors : MOVWF CMCON : BSF STATUS,RP0 ; BANK 1 ' SET REGS IN BANK 1 : MOVLW B'11111111' ; TRISIO=%11111111 'All pins inputs : MOVWF TRISIO : CLRF VRCON ; VRCON=0 ' VRef Off : MOVLW B'00010001' ; ANSEL=%00010001 ' Analog Select : MOVWF ANSEL : BCF STATUS,RP0 ; BANK 0 : MOVLW B'00000001' ; ADCON0=%00000001 ' Analog Configure : MOVWF ADCON0 TRISIO = %11001111 ' Make Clk & Dat outputs HIGH Clk AGAIN: segments = 71 GOSUB SendSegments segments = 15 GOSUB SendSegments segments = 109 GOSUB SendSegments segments = 28 GOSUB SendSegments DELAY 255,255 ' Clear display GOSUB SendSegments GOSUB SendSegments GOSUB SendSegments GOSUB SendSegments DELAY 255,255 GOTO AGAIN SendSegments: FOR cnt=1 TO 8 LOW Dat IF segmentsMSB = 0 THEN DatSet HIGH Dat DatSet: LOW Clk DELAY 10 HIGH Clk DELAY 10 segments = segments << 1 NEXT cnt RETURN END