; ;========================= ; PIC-7SEG02 ;========================= ; ; Copyright 2007 アルゴ算法堂 ; ; 7seg_ledを表示する処理 ; hc138を使用 ; Clock4MHz Internal 版 ; ; 更新履歴 ; ======= ; 07/10/27 Ver.1.00 最初の版(id=0x0310) ; ; 内蔵オシレータではMCLRをGPIOとして使用できない。 ; list p=16f648a #include p16f648a.inc ; CONFIGRATIONS __config _INTOSC_OSC_NOCLKOUT & _PWRTE_ON & _WDT_OFF & _BOREN_ON & _LVP_OFF & _MCLRE_ON & _DATA_CP_OFF & _CP_OFF ; Set User ID Memory __idlocs 0x0310 ; ; ; option_val equ b'10010001' ;b7 RPBU 1: no pullup ;b6 INTEDE 0:nouse rb0/int ;b5 T0CS timer0 clock source 0:FOSC/4 ;b4 T0SE nouse timer0 clock edge ;b3 PSA 0: prescaler to timer0 ;b2-b0 PSn divider ; 0: 1:2 ; 1: 1:4 ; 2: 1:8 ; 3: 1:16 ; 4: 1:32 ; 5: 1:64 ; 6: 1:128 ; 7: 1:255 ; DIGIT_SZ equ 8 ; ; IO BIT INDEX PORTA_ADR_0 equ 0 ;OUT for demultiplexer PORTA_ADR_1 equ 1 ;OUT PORTA_ADR_2 equ 2 ;OUT PORTA_SW_0 equ 3 ;IN PORTA_SW_1 equ 4 ;IN ; PORTB_DATA_0 equ 0 ;OUT for LED segment A PORTB_DATA_1 equ 1 ;OUT for LED segment B PORTB_DATA_2 equ 2 ;OUT for LED segment C PORTB_DATA_3 equ 3 ;OUT for LED segment D PORTB_DATA_4 equ 4 ;OUT for LED segment E PORTB_DATA_5 equ 5 ;OUT for LED segment F PORTB_DATA_6 equ 6 ;OUT for LED segment G PORTB_DATA_7 equ 7 ;OUT for LED segment dot ; PORTA_ADR_MASK equ ((1< no rpg btfsc ctrl,CTRL_RPG movlw 0xff ; blank data ; vramDisp2_norpg: movwf PORTB ; return ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; メイン側の処理 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;-------/ vramClr /---------- ; ; 値を0にする ; vramClr: bsf ctrl,CTRL_INHIBIT clrf digit_count ; movlw vram movwf FSR movlw 8 movwf temp vramClr_loop: clrf INDF incf FSR,f decfsz temp,f goto vramClr_loop ; bcf ctrl,CTRL_INHIBIT return #if 0 ; ;----------/ vramSetDbg1 /------------- ; ; デバッグ用の表示1 ; 現在は未使用 ; ; set debug value to registor ; vramSetDbg1: bsf ctrl,CTRL_INHIBIT clrf digit_count ; movlw 0x01 movwf vram+0 movlw 0x02 movwf vram+1 movlw 0x03 movwf vram+2 movlw 0x04 movwf vram+3 movlw 0x05 movwf vram+4 movlw 0x06 movwf vram+5 movlw 0x07 movwf vram+6 movlw 0x08 movwf vram+7 ; bcf ctrl,CTRL_INHIBIT return ; #endif ; ;-------/ vramSetDemo /--------- ; ; シフトしながらの表示処理 ; ; in demotop: vram top adr ; vramSetDemo: ; bsf ctrl,CTRL_INHIBIT clrf digit_count ; movf demo_top,w movwf demo_adr movlw DIGIT_SZ movwf demo_count movlw vram movwf FSR vramSetDemo_loop: movf demo_adr,w call ReadRom movwf INDF incf demo_adr,f incf FSR,f ; decfsz demo_count,f goto vramSetDemo_loop ; bcf ctrl,CTRL_INHIBIT ; incf demo_top,f movlw EEPROM_MSG_E-8 subwf demo_top,w btfss STATUS,C return movlw EEPROM_MSG movwf demo_top return ;-------/ CountDemo /--------- ; ; カウントアップのデモ ; CountDemo: bsf ctrl,CTRL_INHIBIT clrf digit_count call CountUp bcf ctrl,CTRL_INHIBIT return ; ;------/ CountUp /--------- ; ; カウントアップ本体 ; CountUp: movlw vram+DIGIT_SZ-1 movwf FSR movlw DIGIT_SZ movwf demo_count CountUp_loop: incf INDF,f movlw 0x0a subwf INDF,w btfss STATUS,C return clrf INDF decf FSR,f decfsz demo_count,f goto CountUp_loop return ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; EEPROM ACCESS ; ; ;; ;-------/ ReadRom /-------- ; ; 割り込み内と地面の双方から呼ばれるが ; 大丈夫 ; ; in: w romadr ; out w value ReadRom bsf STATUS,RP0 movwf EEADR bsf EECON1,RD movf EEDATA,w bcf STATUS,RP0 return ;========================= ; EEPROM SECTION ;========================= ; ; 256 bytes ; action data ; ; org 0x2100 eeprom_top: ; ; hexfont ; ls247+hex 6digit ; hexfont: de 0xC0 ; 0 de 0xF9 ; 1 de 0xA4 ; 2 de 0xB0 ; 3 de 0x99 ; 4 de 0x92 ; 5 de 0x82 ; 6 de 0xF8 ; 7 de 0x80 ; 8 de 0x90 ; 9 de 0x88 ; 10 de 0x83 ; 11 de 0xC6 ; 12 de 0xA1 ; 13 de 0x86 ; 14 de 0x8E ; 15 ; ; 74ls47 fonts 0-9 ; ls47font: de 0xC0 ; 0 de 0xF9 ; 1 de 0xA4 ; 2 de 0xB0 ; 3 de 0x99 ; 4 de 0x92 ; 5 de 0x83 ; 6 de 0xF8 ; 7 de 0x80 ; 8 de 0x98 ; 9 ; ; demo1 で使用するメッセージ ; eeprom_msg: de 0x00 ; display test data de 0x00 de 0x00 de 0x00 de 0x00 de 0x00 de 0x00 de 0x00 de 0x01 de 0x02 de 0x03 de 0x04 de 0x05 de 0x06 de 0x07 de 0x08 de 0x09 de 0x00 ; display test data de 0x00 de 0x00 de 0x00 de 0x00 de 0x00 de 0x00 de 0x00 eeprom_msg_e: ; end