;******************************************************************** ; This is an example program for the Hansen Hobbies Mini Scrolling LED Sign Kit. ; Code is written in assembly for Microchip's MPASM assembler. ; This file can be viewed, edited, and assembled with Microchip's MPLAB IDE. ; This file is for reference purposes and may not be used for retail product development. ; Hansen Hobbies will not provide any support for this code. ; DO NOT overwrite the code in your original MLS Kit - we will not provide you with the ; original hex and you will have to buy a new programmed PIC from us. ;******************************************************************** ;******************************************************************** ; The code below very minimally configures the PIC for use in the MLS ; It configures the clock and I/O pins, and also defines the pins for use in code. ; The code simply loops over and over, checking to see if the Up or Down tact ; switches have been pressed. If one is pressed, some pixels are displayed. ;******************************************************************** list p=pic16f1826 include __config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _BOREN_OFF __config _CONFIG2, _PLLEN_OFF & _LVP_OFF ;************ Variables and Constants ************** ;*** Global Variables (16 available) *** cblock 0x70 Count1 ; reusable loop counter endc ;Pin Assignments: #define Row1 PORTA, 0 #define Row2 PORTA, 1 #define Row3 PORTB, 0 #define ShiftData PORTA, 4 #define ShiftClock PORTA, 6 #define Row4 PORTB, 6 #define Row5 PORTA, 2 #define Row6 PORTA, 3 #define Row7 PORTA, 7 #define Row8 PORTB, 7 #define TactL PORTB, 5 #define TactU PORTB, 4 #define TactD PORTB, 3 #define TactR PORTB, 2 ;Constants NumRows EQU d'8' DisplayLength EQU d'24' ; length of the display, in pixels ;******************************************************************** ; Setup Code ; configures all SFR's ;******************************************************************** ORG 0x000 goto Start Start ;Bank 1 banksel TRISA movlw b'00100000' ; all are outputs movwf TRISA movlw b'00111110' ; RB2-RB5 are tact inputs movwf TRISB movlw b'00000000' movwf OPTION_REG ; PORTB has week internal pull up enabled movlw b'01101000' ; 4MHz, Internal Osc movwf OSCCON ;Bank 3 banksel ANSELA clrf ANSELA ; make everything digital (default is analog) clrf ANSELB ;Bank 0 banksel PORTA clrf PORTA clrf PORTB ; any other setup code can be done here ;******************************************************************** ;******************************************************************** ;******************************************************************** ; Main Program Loop ; Runs around in circles ;******************************************************************** Loop call TactCheck ; other things can be done in this loop goto Loop ;******************************************************************** ;******************************************************************** ;******************************************************************** ; User Input Processing ; Debounces and processes inputs from tact switches ;******************************************************************** TactCheck ; if a tact switch was being pressed here is where it needs to be handled ; here is an example that uses the up and down tact switches: btfss TactD call Display_TactD btfss TactU call Display_TactU return ;******************************************************************** ;******************************************************************** ;******************************************************************** ; Display Routine for Scrolling Sign ; Performs all display functions to display ascii characters ;******************************************************************** Display_TactD call Display_Clear call Display_ShiftOne call Display_ShiftZero call Display_ShiftOne call Display_ShiftZero call Display_ShiftOne call Display_ShiftZero call Display_ShiftOne call Display_ShiftZero ; now 01010101 has been shifted out bsf Row1 bsf Row5 ; now the shifted bits will show up on rows 1 and 5 return Display_TactU call Display_Clear call Display_ShiftOne call Display_ShiftZero call Display_ShiftOne call Display_ShiftZero call Display_ShiftOne call Display_ShiftZero call Display_ShiftOne ; now 1010101 has been shifted out bsf Row2 bsf Row4 ; now the shifted bits will show up on rows 2 and 4 return Display_ShiftOne bsf ShiftData ; shift a one bsf ShiftClock bcf ShiftClock return Display_ShiftZero bcf ShiftData ; shift a zero bsf ShiftClock bcf ShiftClock return Display_Clear clrf PORTA bcf Row3 bcf Row4 bcf Row8 movlw DisplayLength movwf Count1 bsf ShiftClock bcf ShiftClock decfsz Count1, F goto $-3 ; this loop will shift out 24 zeros return ;******************************************************************** ;******************************************************************** END