• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
:::


Browsing this Thread:   1 Anonymous Users




« 1 (2)


LCD
#1
新會員
新會員


查看用戶資訊
各位大大
小弟如今又換了新的PIC優,目前初使用的16f946這顆,線路是直接從腳LCDDATAX拉出來控制LCD,這是我目前的程式,現在是朝著利用這些腳位把LCD的部分全點亮,再全暗..再次麻煩各位大大指教指教 謝謝!!
list p=16f946,R=DEC
    
include"p16f946.inc"                              
    
__CONFIG _PWRTE_ON _WDT_OFF _INTRC_OSC_NOCLKOUT 

BANK0 MACRO
    bcf STATUS
,RP1
        bcf STATUS
,RP0 
    ENDM
BANK1 MACRO
    bcf STATUS
,RP1
        bsf STATUS
,RP0 
    ENDM
BANK2 MACRO
    bcf STATUS
,RP1
        bsf STATUS
,RP0
    ENDM
BANK3 MACRO
    bsf STATUS
,RP1
        bsf STATUS
,RP0 
    ENDM



Delay1 equ 0x20
Delay2 equ 0x21
Delay3 equ 0x22

                      
;bank3 
;pic                       ;一萬
#define D9A  LCDDATA13,7    ;*seg39
#define D9F  LCDDATA16,7    ;*
#define D9E  LCDDATA19,7    ;*
#define D9D  LCDDATA22,7    ;*
#define D9B  LCDDATA14,0    ;seg40
#define D9G  LCDDATA17,0    ;
#define D9C  LCDDATA20,0    ;


#define D8A  LCDDATA13,5    ;*seg37
#define D8F  LCDDATA16,5    ;*
#define D8E  LCDDATA19,5    ;*
#define D8D  LCDDATA22,5    ;*
#define D8B  LCDDATA13,6    ;seg38
#define D8G  LCDDATA16,6    ;
#define D8C  LCDDATA19,6    ;

                      
#define D7A  LCDDATA13,3    ;*seg35
#define D7F  LCDDATA16,3    ;*
#define D7E  LCDDATA19,3    ;*
#define D7D  LCDDATA22,3    ;*
#define D7B  LCDDATA13,4    ;seg36
#define D7G  LCDDATA16,4    ;
#define D7C  LCDDATA19,4    ;
                    
#define D6A  LCDDATA13,1    ;*seg33
#define D6F  LCDDATA16,1    ;*
#define D6E  LCDDATA19,1    ;*
#define D6D  LCDDATA22,1    ;*
#define D6B  LCDDATA13,2    ;seg34
#define D6G  LCDDATA16,2    ;
#define D6C  LCDDATA19,2    ;
                     
#define D5A  LCDDATA12,7    ;*seg31
#define D5F  LCDDATA15,7    ;*
#define D5E  LCDDATA18,7    ;*
#define D5D  LCDDATA21,7    ;*
#define D5B  LCDDATA13,0    ;seg32
#define D5G  LCDDATA16,0    ;
#define D5C  LCDDATA19,0    ;
                            
;十萬
#define D12C  LCDDATA15,0    ;*seg24
#define D12G  LCDDATA18,0    ;*
#define D12B  LCDDATA21,0    ;*
#define D12D  LCDDATA12,1    ;*
#define D12E  LCDDATA15,1    ;seg25
#define D12F  LCDDATA18,1    ;
#define D12A  LCDDATA21,1    ;
                         
#define D11C  LCDDATA15,2    ;*seg26
#define D11G  LCDDATA18,2    ;*
#define D11B  LCDDATA21,2    ;*
#define D11D  LCDDATA12,3    ;*
#define D11E  LCDDATA15,3    ;seg27
#define D11F  LCDDATA18,3    ;
#define D11A  LCDDATA21,3    ;

;***********Resect Vector***************
            
org     0x00
            nop
            
;movlw   .25
            
;sublw   .25
            
goto    MainLine
;************  interrupt  **************     
            
org     0x04
           
            
goto    intService

intService
                    
;movwf    W_temp
            
;swapf    STATUS,w
            
;movwf    STATUS_Temp         
             
;btfsc    PIR1,TMR1IF
            
;call    Timer1           
    
            
;swapf    STATUS_Temp,w
            
;movwf    STATUS
            
;swapf    W_temp,f
            
;swapf    W_temp,w
            retfie


;********** Main Program ***************
MainLine
                         
            call    Initial
mainloop            
            call    Display_LCD
            call    Delay250ms
            call    Delay250ms
            call    Delay250ms
            call    Delay250ms
            call    Delay250ms
            call    clear_LCD
            
goto    mainloop
;*********Initial Subroutine************
Initial
            
       BANK3
            clrf    TRISG        
            clrf    TRISF
       BANK2
            clrf    TRISE

       BANK1
            movlw   07h             
            movwf   CMCON0              
CMCON1無法關      
       
                                             
;InitLCD
       BANK2                                      
          
            movlw 
b'10011110'                 operates in sleep1/3 mux1/3 biasinternal RC osc,
            
movwf LCDCON                     init lcd control registerinternal voltage generator used
            movlw 
b'10110010'                1/3 muxframe freq = ?kHz/(85*(3+1)) = about Hz[Clock source / (96 * (LP3:LP0 1))]
            
movwf LCDPS                                                 
                
                
           
return



 
;*******************************************************************
;* 
The LCD Module Subroutines                                      *
;* 
Command sequence for 2 lines of 5x16 characters                 *
;*******************************************************************
Display_LCD
        BANK3
                                
; ***全數點亮****;
                                ;
pic                   
             bsf D9A  
             bsf D9F  
             bsf D9E  
             bsf D9D  
             bsf D9B  
             bsf D9G  
             bsf D9C  

             bsf D8A  
             bsf D8F  
             bsf D8E  
             bsf D8D  
             bsf D8B  
             bsf D8G  
             bsf D8C  

             bsf D7A  
             bsf D7F 
             bsf D7E  
             bsf D7D  
             bsf D7B  
             bsf D7G  
             bsf D7C 
                    
             bsf D6A
             bsf D6F  
             bsf D6E  
             bsf D6D  
             bsf D6B  
             bsf D6G  
             bsf D6C  
                     
             bsf D5A  
             bsf D5F 
             bsf D5E  
             bsf D5D  
             bsf D5B  
             bsf D5G  
             bsf D5C  
        
             bsf D12C  
             bsf D12G 
             bsf D12B  
             bsf D12D  
             bsf D12E  
             bsf D12F  
             bsf D12A  
                         
             bsf D11C  
             bsf D11G  
             bsf D11B  
             bsf D11D  
             bsf D11E  
             bsf D11F  
             bsf D11A     
             
return 

clear_LCD
            BANK3
                                
; ***全數off****;
                                ;
pic                   
             bcf D9A  
             bcf D9F  
             bcf D9E  
             bcf D9D  
             bcf D9B  
             bcf D9G  
             bcf D9C  

             bcf D8A  
             bcf D8F  
             bcf D8E  
             bcf D8D  
             bcf D8B  
             bcf D8G  
             bcf D8C  

             bcf D7A  
             bcf D7F 
             bcf D7E  
             bcf D7D  
             bcf D7B  
             bcf D7G  
             bcf D7C 
                    
             bcf D6A
             bcf D6F  
             bcf D6E  
             bcf D6D  
             bcf D6B  
             bcf D6G  
             bcf D6C  
                     
             bcf D5A  
             bcf D5F 
             bcf D5E  
             bcf D5D  
             bcf D5B  
             bcf D5G  
             bcf D5C  
        
             bcf D12C  
             bcf D12G 
             bcf D12B  
             bcf D12D  
             bcf D12E  
             bcf D12F  
             bcf D12A  
                         
             bcf D11C  
             bcf D11G  
             bcf D11B  
             bcf D11D  
             bcf D11E  
             bcf D11F  
             bcf D11A 
             
return 
;------------------------------------------------------------------------------
; Function: 
Delay1ms
OverviewThis is a very accurate 1ms delay for a 4MHz clock.
;------------------------------------------------------------------------------
Delay1ms:
        
movlw    .198
        movwf    Delay1
        nop
        nop
Delay1ms_01
:
        
nop
        nop
        decfsz    Delay1
F
        
goto    Delay1ms_01
        retlw    0x00
;------------------------------------------------------------------------------
; Function: 
Delay250ms
Overview:
;------------------------------------------------------------------------------
Delay250ms:
        
movlw    .250
        movwf    Delay2
Delay250ms_01
:
        
call    Delay1ms
        
;CLRWDT
        decfsz    Delay2
F
        
goto    Delay250ms_01
        retlw    0x00

;------------------------------------------------------------------------------
; Function: 
Delay3s
Overview:
;------------------------------------------------------------------------------        
Delay3s:        
        
movlw    .8        ;2sec
        movwf    Delay3
Delay3s1
:        
        
call    Delay250ms
        decfsz    Delay3
        
goto    Delay3s1
        retlw    0x00
        
 End

發表於: 2009/8/25 0:28
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------