初級會員
Joined
: 2006/4/16 15:59 最後登入時間
: 2008/1/14 20:53
Group:
註冊會員
Level : 3 HP : 0 / 73 MP : 9 / 3959 EXP : 93
|
想讓APP01 板子上的LCD 有被控制到下面寫的程式對嗎 l list p=18f452,r=dec #include p18f452.inc
;----- include variable ----- extern LCD_Temp ;----- include function ----- extern LCD_Put_Cmd,LCD_Display,LCD_Clear,LCD_Entry ;----- Code start ----- P_Code code ;----- LCD initial ----- LCD_Initial: global LCD_Initial clrf TRISD,0 movlw 0xf8 andwf TRISD,F,0 clrf LATD,0 clrf LATD,0 bcf INTCON2,RBPU,0
movlw 0x30 call LCD_Put_Cmd movlw 0x30 call LCD_Put_Cmd movlw 0x30 call LCD_Put_Cmd movlw 0x38 call LCD_Put_Cmd movlw 0x0e call LCD_Display call LCD_Clear movlw 0x06 call LCD_Entry return end
;lcd command list p=18f452,r=dec #include p18f452.inc
;----- include variable ----- extern LCD_Temp ;----- include function ----- extern X_Delay500 ;----- Code start ----- P_Code code ;****************************************** ;Send command to LCD ;The command is in W ;****************************************** LCD_Put_Cmd: global LCD_Put_Cmd movwf LCD_Temp,0 call Check_LCD_Busy movlw 0x04 movwf LATD,0 movff LCD_Temp,LATB movlw 0x00 movwf LATD,0 movlw 0x1e call X_Delay500 return
;****************************************** ;****** Check LCD Busy flag *************** ;****************************************** Check_LCD_Busy: global Check_LCD_Busy movlw 0xff movwf TRISD,0
Check_Flag: movlw 0x06 movwf LATA,2 movf PORTD,W,0 andlw 0x80 btfss STATUS,Z,0 goto Check_Flag clrf TRISD,0 return
;****************************************** ;********** Display control *************** ;****************************************** LCD_Display: global LCD_Display andlw 0x07 iorlw 0x08 call LCD_Put_Cmd return
;****************************************** ;********** Clear LCD monitor ************* ;****************************************** LCD_Clear: global LCD_Clear movlw 0x01 call LCD_Put_Cmd return
;****************************************** ;************ Set LCD entry *************** ;****************************************** LCD_Entry: global LCD_Entry andlw 0x03 iorlw 0x04 call LCD_Put_Cmd return
;****************************************** ;************* Cursor go home ************* ;****************************************** LCD_Home: global LCD_Home movlw 0x02 call LCD_Put_Cmd return
;****************************************** ;******** Set CGRAN's address ************* ;****************************************** LCD_Set_CGA: global LCD_Set_CGA andlw 0x3f iorlw 0x40 call LCD_Put_Cmd return
;****************************************** ;********* Set DDRAM;s address ************ ;****************************************** LCD_Set_DDA: global LCD_Set_DDA iorlw 0x80 call LCD_Put_Cmd return
;****************************************** ;*********** Read_LCD_Cursor ************** ;****************************************** Read_LCD_Cursor: global Read_LCD_Cursor movlw 0xff movwf TRISD,0 movlw 0x06 movwf LATE,0 clrf TRISD,0 movf LATD,W,0 return
;****************************************** ;*********** LCD_Put_Char ***************** ;****************************************** LCD_Put_Char: global LCD_Put_Char movwf LCD_Temp,0 call Check_LCD_Busy movlw 0x05 movwf LATA,2 movff LCD_Temp,LATB movlw 0x01 movwf LATD,0 movlw 0x1e call X_Delay500 return
;******************************************
end
發表於: 2006/4/29 22:14
|