16f84 à 16f877
Répondre à la discussion
Affichage des résultats 1 à 27 sur 27

16f84 à 16f877



  1. #1
    sdow

    16f84 à 16f877


    ------

    salut

    est ce que vous pouvez m'aider à adapter ce code à 16f877.

    Code:
    RESET_V		EQU	0x0000		; Address of RESET Vector
    ISR_V		EQU	0x0004		; Address of Interrupt Vector
    OSC_FREQ	EQU	D'4000000'	; Oscillator Frequency is 4 MHz
    
    LCD_DATA	EQU	PORTB		; LCD data lines interface
    LCD_DATA_TRIS	EQU	TRISB
    LCD_CTRL	EQU	PORTA		; LCD control lines interface
    
    LCD_LINE0	EQU	0x000
    LCD_LINE1	EQU	0x040
    LCD_LINE2	EQU	0x014
    LCD_LINE3	EQU	0x054
    
    ; PORTA bits
    LCD_E		EQU	2		; LCD Enable control line
    LCD_RW		EQU	1		; LCD Read/Write control line
    LCD_RS		EQU	0		; LCD Register-Select control line
    
    ; PORTB bits
    DB7		EQU	7		; LCD dataline 7 (MSB)
    DB6		EQU	6		; LCD dataline 6
    DB5		EQU	5		; LCD dataline 5
    DB4		EQU	4		; LCD dataline 4
    DB3		EQU	3		; LCD dataline 3
    DB2		EQU	2		; LCD dataline 2
    DB1		EQU	1		; LCD dataline 1
    DB0		EQU	0		; LCD dataline 0 (LSB)
    
    ; misc.
    LCD_TEMP	EQU	0x020		; LCD subroutines internal use
    
    TABLE_INDEX	EQU	0x021		; Index to table strings
    COUNT		EQU	0x022		; A counter
    DELAY		equ	0x023		; Used in DELAYxxx routines
    X_DELAY		equ	0x024		; Used in X_DELAYxxx routines
    
    
    	ORG     0x000             ; processor reset vector
    
    	nop			  ; nop required for icd
      	goto    START              ; go to beginning of program
    
    
    TABLE_MSG
    		MOVLW	0		; Startindex of table message
    DISP_MSG
    		MOVWF	TABLE_INDEX	; Holds message address
    		CALL	MSG1
    		ANDLW	0x0FF		; Check if at end of message
    		BTFSC	STATUS, Z	; (zero returned at end)
    		GOTO	TABLE_MSG_END             
    		CALL	LCDPUTCHAR	; Display character
    		MOVF	TABLE_INDEX, W	; Point to next character
    		ADDLW	1
    		GOTO	DISP_MSG
    TABLE_MSG_END	RETURN
    
    TABLE_MSG1
    		MOVLW	0		; Startindex of table message
    DISP_MSG1
    		MOVWF	TABLE_INDEX	; Holds message address
    		CALL	MSG2
    		ANDLW	0x0FF		; Check if at end of message
    		BTFSC	STATUS, Z	; (zero returned at end)
    		GOTO	TABLE_MSG_END1             
    		CALL	LCDPUTCHAR	; Display character
    		MOVF	TABLE_INDEX, W	; Point to next character
    		ADDLW	1
    		GOTO	DISP_MSG1
    TABLE_MSG_END1	RETURN
    
    
    TABLE_MSG2
    		MOVLW	0		; Startindex of table message
    DISP_MSG2
    		MOVWF	TABLE_INDEX	; Holds message address
    		CALL	MSG3
    		ANDLW	0x0FF		; Check if at end of message
    		BTFSC	STATUS, Z	; (zero returned at end)
    		GOTO	TABLE_MSG_END2             
    		CALL	LCDPUTCHAR	; Display character
    		MOVF	TABLE_INDEX, W	; Point to next character
    		ADDLW	1
    		GOTO	DISP_MSG2
    TABLE_MSG_END2	RETURN
    
    
    TABLE_MSG3
    		MOVLW	0		; Startindex of table message
    DISP_MSG3
    		MOVWF	TABLE_INDEX	; Holds message address
    		CALL	MSG1
    		ANDLW	0x0FF		; Check if at end of message
    		BTFSC	STATUS, Z	; (zero returned at end)
    		GOTO	TABLE_MSG_END3             
    		CALL	LCDPUTCHAR	; Display character
    		MOVF	TABLE_INDEX, W	; Point to next character
    		ADDLW	1
    		GOTO	DISP_MSG3
    TABLE_MSG_END3	RETURN
    
    
    TABLE_VIT
    		MOVLW	0		; Startindex of table message
    VIT
    		MOVWF	TABLE_INDEX	; Holds message address
    		CALL	MSG5
    		ANDLW	0x0FF		; Check if at end of message
    		BTFSC	STATUS, Z	; (zero returned at end)
    		GOTO	TABLE_VIT_END3             
    		CALL	LCDPUTCHAR	; Display character
    		MOVF	TABLE_INDEX, W	; Point to next character
    		ADDLW	1
    		GOTO	VIT
    TABLE_VIT_END3	RETURN		
    
    
    ;=========================================================
    ; LCDINIT
    ; Initilize LC-Display Module
    ; Should be modified to your needs (i.e. display type, cursor on/off, etc.)
    ; OK
    ;=========================================================
    LCDINIT
    					; Busy-flag is not yet valid
    		CLRF	LCD_CTRL	; ALL PORT output should output Low.
    					; power-up delay
    		MOVLW	0x01E
    		CALL	X_DELAY500	; 30 * 0.5mS = 15mS
    					; Busy Flag should be valid from here
    		MOVLW	0x038		; 8-bit-interface, 2-lines
    		CALL	LCDPUTCMD
    		MOVLW	0x000		; disp.off, curs.off, no-blink
    		CALL	LCDDMODE
    		CALL	LCDCLEAR
    		MOVLW	0x004		; disp.on, curs.off
    		CALL	LCDDMODE
    		MOVLW	0x002		; auto-inc (shift-cursor)
    		CALL	LCDEMODE
    		RETURN
    ;=========================================================
    ; LCD_ENABLE
    ; Pulses LCD enable pin
    ; OK
    ;=========================================================
    LCD_ENABLE
    		BSF	LCD_CTRL, LCD_E	; LCD E-line High
    		BCF	LCD_CTRL, LCD_E	; LCD E-line Low
    		RETURN
    ;=========================================================
    ; LCDBUSY
    ; Returns when LCD busy-flag is inactive
    ; OK
    ;=========================================================
    LCDBUSY
    		BSF	STATUS,RP0	; Select Register page 1
    		MOVLW	0x0FF		; Set PORTB for input
    		MOVWF	LCD_DATA_TRIS
    		BCF	STATUS, RP0	; Select Register page 0
    		BCF	LCD_CTRL, LCD_RS; Set LCD for command mode
    		BSF	LCD_CTRL, LCD_RW; Setup to read busy flag
    		BSF	LCD_CTRL, LCD_E	; LCD E-line High
    		MOVF	LCD_DATA, W	; Read busy flag + DDram address
    		BCF	LCD_CTRL, LCD_E	; LCD E-line Low
    		ANDLW	0x80		; Check Busy flag, High = Busy
    		BTFSS	STATUS, Z
    		GOTO	LCDBUSY
    LCDNOTBUSY	BCF	LCD_CTRL, LCD_RW
    		BSF	STATUS, RP0	; Select Register page 1
    		MOVLW	0x000
    		MOVWF	LCD_DATA_TRIS	; Set PORTB for output
    		BCF	STATUS, RP0	; Select Register page 0
    		RETURN
    ;=========================================================
    ; LCDCLEAR
    ; Clears display and returns cursor to home position (upper-left corner).
    ;
    ;=========================================================
    LCDCLEAR
    		MOVLW	0x001
    		CALL	LCDPUTCMD
    		RETURN
    ;=========================================================
    ; LCDHOME
    ; Returns cursor to home position.
    ; Returns display to original position (when shifted).
    ;
    ;=========================================================
    LCDHOME
    		MOVLW	0x002
    		CALL	LCDPUTCMD
    		RETURN
    ;=========================================================
    ; LCDEMODE
    ; Sets entry mode of display.
    ; Required entry mode must be set in W
    ;  b0	: 0 = no display shift	1 = display shift
    ;  b1	: 0 = auto-decrement	1 = auto-increment
    ;  b2-7	: don't care
    ; OK
    ;=========================================================
    LCDEMODE
    		ANDLW	0x003		; Strip upper bits
    		IORLW	0x004		; Function set
    		CALL	LCDPUTCMD
    		RETURN
    ;=========================================================
    ; LCDDMODE
    ; Sets display control.
    ; Required display mode must be set in W
    ;  b0	: 0 = cursor blink off	1 = cursor blink on
    ;  b1	: 0 = cursor off	1 = cursor on
    ;  b2	: 0 = display off	1 = display on (display data remains in DDRAM)
    ;  b3-7	: don't care
    ; OK
    ;=========================================================
    LCDDMODE
    		ANDLW	0x007		; Strip upper bits
    		IORLW	0x008		; Function set
    		CALL	LCDPUTCMD
    		RETURN
    ;=========================================================
    ; LCDSCGA
    ; Sets Character-Generator-RAM address. CGRAM is read/written after
    ;  this setting.
    ; Required CGRAM address must be set in W
    ;  b0-5	: required CGRAM address
    ;  b6-7	: don't care
    ;
    ;=========================================================
    LCDSCGA
    		ANDLW	0x03F		; Strip upper bits
    		IORLW	0x040		; Function set
    		CALL	LCDPUTCMD
    		RETURN
    ;=========================================================
    ; LCDSDDA
    ; Sets the Display-Data-RAM address. DDRAM data is read/written after
    ;  this setting.
    ; Required DDRAM address must be set in W
    ;  b0-6	: required DDRAM address
    ;  b7	: don't care
    ; OK
    ;=========================================================
    LCDSDDA
    		IORLW	0x080		; Function set
    		CALL	LCDPUTCMD
    		RETURN
    ;=========================================================
    ; LCDGADDR
    ; Returns address counter contents, used for both DDRAM and CGRAM.
    ; RAM address is returned in W
    ;
    ;=========================================================
    LCDGADDR
    		BSF	STATUS,RP0	; Select Register page 1
    		MOVLW	0x0FF		; Set PORTB for input
    		MOVWF	LCD_DATA_TRIS
    		BCF	STATUS, RP0	; Select Register page 0
    		BCF	LCD_CTRL, LCD_RS; Set LCD for command mode
    		BSF	LCD_CTRL, LCD_RW; Setup to read busy flag
    		BSF	LCD_CTRL, LCD_E	; LCD E-line High
    		MOVF	LCD_DATA, W	; Read busy flag + RAM address
    		BCF	LCD_CTRL, LCD_E	; LCD E-line Low
    		ANDLW	0x07F		; Strip upper bit
    		BCF	LCD_CTRL, LCD_RW
    		BSF	STATUS, RP0	; Select Register page 1
    		MOVLW	0x000
    		MOVWF	LCD_DATA_TRIS	; Set PORTB for output
    		BCF	STATUS, RP0	; Select Register page 0
    		RETURN
    ;=========================================================
    ; LCDPUTCHAR
    ; Sends character to LCD
    ; Required character must be in W
    ; OK
    ;=========================================================
    LCDPUTCHAR
    		MOVWF	LCD_TEMP	; Character to be sent is in W
    		CALL	LCDBUSY		; Wait for LCD to be ready
    		BCF	LCD_CTRL, LCD_RW; Set LCD in read mode
    		BSF	LCD_CTRL, LCD_RS; Set LCD in data mode
    		BSF	LCD_CTRL, LCD_E	; LCD E-line High
    		MOVF	LCD_TEMP, W
    		MOVWF	LCD_DATA	; Send data to LCD
    		BCF	LCD_CTRL, LCD_E	; LCD E-line Low
    		RETURN
    ;=========================================================
    ; LCDPUTCMD
    ; Sends command to LCD
    ; Required command must be in W
    ; OK
    ;=========================================================
    LCDPUTCMD
    		MOVWF	LCD_TEMP	; Command to be sent is in W
    		CALL	LCDBUSY		; Wait for LCD to be ready
    		BCF	LCD_CTRL, LCD_RW; Set LCD in read mode
    		BCF	LCD_CTRL, LCD_RS; Set LCD in command mode
    		BSF	LCD_CTRL, LCD_E	; LCD E-line High
    		MOVF	LCD_TEMP, W
    		MOVWF	LCD_DATA	; Send data to LCD
    		BCF	LCD_CTRL, LCD_E	; LCD E-line Low
    		RETURN
    
    
    
    
    
    
    ;*********************************************************
    ; Delay_time	= ((DELAY_value * 3) + 4) * Cycle_time
    ; DELAY_value	= (Delay_time - (4 * Cycle_time)) / (3 * Cycle_time)
    ;
    ; i.e. (@ 4MHz crystal)
    ; Delay_time	= ((32 * 3) + 4) * 1uSec
    ;		= 100uSec
    ; DELAY_value	= (500uSec - 4) / 3
    ;		= 165.33
    ;		= 165
    ;*********************************************************
    DELAY500	MOVLW	D'165'		; +1		1 cycle
    		MOVWF	DELAY		; +2		1 cycle
    DELAY500_LOOP	DECFSZ	DELAY, F	; step 1	1 cycle
    		GOTO	DELAY500_LOOP	; step 2	2 cycles
    DELAY500_END	RETURN			; +3		2 cycles
    ;
    ;
    X_DELAY500	MOVWF	X_DELAY		; +1		1 cycle
    X_DELAY500_LOOP	CALL	DELAY500	; step1		wait 500uSec
    		DECFSZ	X_DELAY, F	; step2		1 cycle
    		GOTO	X_DELAY500_LOOP	; step3		2 cycles
    X_DELAY500_END	RETURN			; +2		2 cycles
    
    
    
    
    
    
    ;=========================================================
    ; Table message to display
    ;=========================================================
    MSG1
    		addwf	PCL ,F		;Jump to char pointed to in W reg
    		retlw	'+'
    		retlw	'+'
    		retlw	'+'
    		retlw	'+'
    		retlw	'+'
    		retlw	'+'
    		retlw	'+'
    		retlw	'+'
    		retlw	'+'
    		retlw	'+'
    		retlw	'+'
    		retlw	'+'
    		retlw	'+'
    		retlw	'+'
    		retlw	'+'
    		retlw	'+'
    		retlw	'+'
    		retlw	'+'
    		retlw	'+'
    		
    MSG1_END
    		retlw	0
    ;
    	IF ( (MSG1 & 0x0FF) >= (MSG1_END & 0x0FF) )
    		MESSG   "Warning - User Definded: Table 'MSG1' crosses page boundry in computed jump"
    	ENDIF
    	return 
    
    	
    MSG2
    		addwf	PCL ,F		;Jump to char pointed to in W reg
    		retlw	'+'
    		retlw	' '
    		retlw	' '
    		retlw	' '
    		retlw	'R'
    		retlw	'O'
    		retlw	'B'
    		retlw	'O'
    		retlw	'T'
    		retlw	'O'
    		retlw	'S'
    		retlw	' '
    		retlw	' '
    		retlw	'.'
    		retlw	' '
    		retlw	' '
    		retlw	' '
    		retlw	' '
    		retlw	' '
    		
    MSG2_END
    		retlw	0
    ;
    	IF ( (MSG2 & 0x0FF) >= (MSG2_END & 0x0FF) )
    		MESSG   "Warning - User Definded: Table 'MSG1' crosses page boundry in computed jump"
    	ENDIF
    	return 	
    
    MSG3
    		addwf	PCL ,F		;Jump to char pointed to in W reg
    		retlw	'+'
    		retlw	' '
    		retlw	' '
    		retlw	'F'
    		retlw	'4'
    		retlw	' '
    		retlw	'p'
    		retlw	'o'
    		retlw	'u'
    		retlw	'r'
    		retlw	' '
    		retlw	'E'
    		retlw	'N'
    		retlw	'T'
    		retlw	'R'
    		retlw	'E'
    		retlw	'R'
    		retlw	' '
    		retlw	' '
    		
    MSG3_END
    		retlw	0
    ;
    	IF ( (MSG3 & 0x0FF) >= (MSG3_END & 0x0FF) )
    		MESSG   "Warning - User Definded: Table 'MSG1' crosses page boundry in computed jump"
    	ENDIF
    	return 	
    	
    	
    	
    MSG5
    		addwf	PCL ,F		;Jump to char pointed to in W reg
    		retlw	'L'
    		retlw	'a'
    		retlw	' '
    		retlw	'V'
    		retlw	'i'
    		retlw	't'
    		retlw	'e'
    		retlw	's'
    		retlw	's'
    		retlw	'e'
    		retlw	' '
    		retlw	'e'
    		retlw	's'
    		retlw	't'
    		retlw	':'
    		retlw	' '
    		retlw	' '
    		retlw	' '
    		retlw	' '
    		
    MSG5_END
    		retlw	0
    ;
    	IF ( (MSG5 & 0x0FF) >= (MSG5_END & 0x0FF) )
    		MESSG   "Warning - User Definded: Table 'MSG1' crosses page boundry in computed jump"
    	ENDIF
    	return 	
    	
    	
    INDEX	
    		call	LCDCLEAR
    		MOVLW	'+'		; ASCII '0'
    		MOVWF	COUNT
    		MOVLW	LCD_LINE0
    		CALL	LCDSDDA		; Position cursor leftmost on first line
    		CALL	TABLE_MSG	; Display message
    		MOVLW	LCD_LINE0 + 0x013
    		CALL	LCDSDDA		; Position cursor
    		MOVF	COUNT, W
    		CALL	LCDPUTCHAR	; Display line number
    		
    		MOVLW	'+'		; ASCII '0'
    		MOVWF	COUNT
    		MOVLW	LCD_LINE1
    		CALL	LCDSDDA		; Position cursor leftmost on first line
    		CALL	TABLE_MSG1	; Display message
    		MOVLW	LCD_LINE1 + 0x013
    		CALL	LCDSDDA		; Position cursor
    		MOVF	COUNT, W
    		CALL	LCDPUTCHAR	; Display line number
    		
    		MOVLW	'+'		; ASCII '0'
    		MOVWF	COUNT
    		MOVLW	LCD_LINE2
    		CALL	LCDSDDA		; Position cursor leftmost on first line
    		CALL	TABLE_MSG2	; Display message
    		MOVLW	LCD_LINE2 + 0x013
    		CALL	LCDSDDA		; Position cursor
    		MOVF	COUNT, W
    		CALL	LCDPUTCHAR	; Display line number
    		
    		MOVLW	'+'		; ASCII '0'
    		MOVWF	COUNT
    		MOVLW	LCD_LINE3
    		CALL	LCDSDDA		; Position cursor leftmost on first line
    		CALL	TABLE_MSG3	; Display message
    		MOVLW	LCD_LINE3 + 0x013
    		CALL	LCDSDDA		; Position cursor
    		MOVF	COUNT, W
    		CALL	LCDPUTCHAR	; Display line number
    		
    		RETURN
    VITESSE
    		CALL    LCDCLEAR
    		MOVLW	' '		; ASCII '0'
    		MOVWF	COUNT
    		MOVLW	LCD_LINE0
    		CALL	LCDSDDA		; Position cursor leftmost on first line
    		CALL	TABLE_MSG1	; Display message
    		MOVLW	LCD_LINE0 + 0x013
    		CALL	LCDSDDA		; Position cursor
    		MOVF	COUNT, W
    		CALL	LCDPUTCHAR	; Display line number
    
    		MOVLW	' '		; ASCII '0'
    		MOVWF	COUNT
    		MOVLW	LCD_LINE2
    		CALL	LCDSDDA		; Position cursor leftmost on first line
    		CALL	TABLE_VIT	; Display message
    		MOVLW	LCD_LINE2 + 0x013
    		CALL	LCDSDDA		; Position cursor
    		MOVF	COUNT, W
    		CALL	LCDPUTCHAR	; Display line number	
    		RETURN
    
    Niveau
    
    step1
    		call  DELAY500	
    		btfss PORTA,3
    		goto step1
    step2   
    		call  DELAY500
    		btfsc PORTA,3
    		goto  step2	
    step3	
    		call DELAY500	
    		btfss PORTA,3
    		goto step3			
    		return		
    		
    ;*****************************************************************************
    ; Initialize processor registers
    ;*****************************************************************************
    START					; POWER_ON Reset (Beginning of program)
    		CLRF	STATUS		; Do initialization, Select bank 0
    		CLRF	INTCON		; Clear int-flags, Disable interrupts
    		CLRF	PCLATH		; Keep in lower 2KByte
    
    		CLRF	PORTA		; ALL PORT output should output Low.
    		CLRF	PORTB
    
    		BSF		STATUS, RP0	; Select bank 1
    		MOVLW	0x0F8		; RA2-0 outputs, RA4-3 inputs
    		MOVWF	TRISA
    		MOVLW	0x000		; RB7-0 outputs
    		MOVWF	TRISB
    		BSF		OPTION_REG, NOT_RBPU ; Disable PORTB pull-ups
    	
    		BCF	STATUS, RP0	; Select bank 0
    
    		CALL	LCDINIT		; Initialize LCDisplay
    
    
    
    			
    loop
    	
    		CALL INDEX	
    				
    		call Niveau
    		call VITESSE
    		call Niveau
    		goto loop
    
    		
    END

    -----

  2. #2
    DavidDB

    Re : 16f84 à 16f877

    Salut,

    Il manque les 3/4 du programme...

    Sinon, pour la partie du code que tu présentes dans le post #1, il n'y a rien à changer pour passer du 16F84 au 16f877.

    David.

  3. #3
    sdow

    Re : 16f84 à 16f877

    salut le code que je te présente ici fonction très bien avec 16f84

    mais pas avec 877

  4. #4
    freepicbasic

    Re : 16f84 à 16f877

    Voir la page 29 du datasheet
    pour mettre toute les pins du portA en digital
    Code:
    movlw 6
    movwf ADCON1
    A+, pat

  5. A voir en vidéo sur Futura
  6. #5
    DavidDB

    Re : 16f84 à 16f877

    Dans "START",

    Il faut invalider les entrées analoqiques du 16f877 présentent sur le portA, qui n'existe pas sur le 16F84.

    David.

    Edit : pas vu la réponse de pat...
    Dernière modification par DavidDB ; 03/06/2007 à 16h20. Motif: trop lent...

  7. #6
    sdow

    Re : 16f84 à 16f877

    dans le start je met

    movlw 6
    movwf ADCON1

    mais ça ne fonctionne pas

  8. #7
    DavidDB

    Re : 16f84 à 16f877

    ADCON1 est en bank1...

    David.

  9. #8
    sdow

    Re : 16f84 à 16f877

    ça ne marche pas

  10. #9
    freepicbasic

    Re : 16f84 à 16f877

    ne pas oublier bank1 puis le retour bank0 après le adcon1.
    voir la vitesse du delay aussi si l'on passede 4mhz à 20 mhz
    A+, pat

  11. #10
    sdow

    Re : 16f84 à 16f877

    Code:
    CLRF	STATUS		; Do initialization, Select bank 0
    		CLRF	INTCON		; Clear int-flags, Disable interrupts
    		CLRF	PCLATH		; Keep in lower 2KByte
    
    		CLRF	PORTA		; ALL PORT output should output Low.
    		CLRF	PORTB
    
    		BSF		STATUS, RP0	; Select bank 1
    		MOVLW	0x0F8		; RA2-0 outputs, RA4-3 inputs
    		MOVWF	TRISA
    		MOVLW	0x000		; RB7-0 outputs
    		MOVWF	TRISB
    		BSF		OPTION_REG, NOT_RBPU ; Disable PORTB pull-ups
    	             movlw 6
                             movwf ADCON1
    		BCF	STATUS, RP0	; Select bank 0
    
    		CALL	LCDINIT		; Initialize LCDisplay
    
    
    
    			
    loop
    	
    		CALL INDEX	
    				
    		call Niveau
    		call VITESSE
    		call Niveau
    		goto loop
    
    		
    END

  12. #11
    DavidDB

    Re : 16f84 à 16f877

    Je ne comprends pas comment ce programme peut fonctionner sur 16F84...

    Jusqu'à la FIN de la phase d'initialisation du LCD, il est INTERDIT de vérifier BUSY FLAG...
    Or, dans l'init du LCD dès la première commande, tu testes BUSY FLAG ce qui empêche une initialisation correct du LCD...

    Donc, il est impossible que ce programme fonctionne tel quel sur 16F84!

    David.

  13. #12
    sdow

    Re : 16f84 à 16f877

    Pourrais-tu ajouter les lignes dans mon code, car je ne comprends pas.

  14. #13
    DavidDB

    Re : 16f84 à 16f877

    Salut,

    Non, je ne corrige pas ton code...

    Tu ouvres le datasheet d'un LCD, et tu adaptes ton programme en suivant à la lettre la procédure d'initialisation!

    Je n'apprécie pas le fait que tu dises que ton programme fonctionne sur 16F84, alors qu'une lecture rapide de ton code montre des erreurs flagrantes rendant impossible la mise en service du LCD.
    Et ceci n'a rien avoir avec la migration du programme d'un 16f84 vers 16f877 (Pat a donné l'unique modification à faire dans ton cas)

    David.

  15. #14
    sdow

    Re : 16f84 à 16f877

    tout les code sont là

    http://home.iae.nl/users/pouweha/lcd/lcd.shtml

    si tu veux esayer sur un 84 tout marchera

  16. #15
    DavidDB

    Re : 16f84 à 16f877

    Non, cela ne fonctionne pas!

    Un extrait d'un datasheet LCD (idem au HDxxx):

    During the initialization, the following instructions are executed, and BF (Busy Flag) is kept “High” (busy state) to
    the end of initialization
    .

    Il faut utiliser des tempos jusqu'a la fin de l'initialisation comme mentionné dans le datasheet pour un fonctionnement correct du LCD.

    David.

  17. #16
    sdow

    Re : 16f84 à 16f877

    Code:
    LCDINIT
    					; Busy-flag is not yet valid
    		CLRF	LCD_CTRL	; ALL PORT output should output Low.
    					; power-up delay
    		MOVLW	0x01E
    		CALL	X_DELAY500	; 30 * 0.5mS = 15mS
    					; Busy Flag should be valid from here
    		MOVLW	0x038		; 8-bit-interface, 2-lines
    		CALL	LCDPUTCMD
                              MOVLW	0x01E
    		CALL	X_DELAY500	; 30 * 0.5mS = 15mS
    		MOVLW	0x000		; disp.off, curs.off, no-blink
    		CALL	LCDDMODE
                              MOVLW	0x01E
    		CALL	X_DELAY500	; 30 * 0.5mS = 15mS
    		CALL	LCDCLEAR
                              MOVLW	0x01E
    		CALL	X_DELAY500	; 30 * 0.5mS = 15mS
    		MOVLW	0x004		; disp.on, curs.off
    		CALL	LCDDMODE
                              MOVLW	0x01E
    		CALL	X_DELAY500	; 30 * 0.5mS = 15mS
    		MOVLW	0x002		; auto-inc (shift-cursor)
    		CALL	LCDEMODE
                              MOVLW	0x01E
    		CALL	X_DELAY500	; 30 * 0.5mS = 15mS 
    		RETURN

  18. #17
    DavidDB

    Re : 16f84 à 16f877

    C'est bien essayé, mais ce n'est juste...

    Le test de Busy Flag se fait par l'intermédiaire de la routine "LCDPUTCMD" et donc les delais que tu as rajouté ne servent à rien et ne corrige pas le problème.

    Est-ce que tu comprends le code de ce programme ?

    David.

  19. #18
    sdow

    Re : 16f84 à 16f877

    donc je met un delais dans la fonction LCDPUTCMD

  20. #19
    freepicbasic

    Re : 16f84 à 16f877

    Or, dans l'init du LCD dès la première commande, tu testes BUSY FLAG ce qui empêche une initialisation correct du LCD...
    Il a mis une tempo dans son init
    Code:
    		CALL	X_DELAY500	; 30 * 0.5mS = 15mS
    Comme je disais le fait de passer de 4mhz à 20mhz diminue le temps.
    Peut être que ça suffit avec le Pic16F84 à 4mhz.
    Si c'est vrai que ça fonctionne avec un Pic16F84...

    J'ai déjà fait ce portage, avec mes prog, il y a juste le ADCON1 à ajouter et porter les tempos ,c'est tout ...
    A+, pat

  21. #20
    sdow

    Re : 16f84 à 16f877

    pourquoi mplab me dit :

    Code:
    Warning[215] C:\WINDOWS\BUREAU\LCD877\LCD877.ASM 43 : Processor superseded by command line.  Verify processor symbol.
    Message[301] C:\PROGRAM FILES\MPLAB IDE\MCHIP_TOOLS\P16F877A.INC 36 : MESSAGE: (Processor-header file mismatch.  Verify selected processor.)
    Message[302] C:\WINDOWS\BUREAU\LCD877\LCD877.ASM 234 : Register in operand not in bank 0.  Ensure that bank bits are correct.
    Message[302] C:\WINDOWS\BUREAU\LCD877\LCD877.ASM 247 : Register in operand not in bank 0.  Ensure that bank bits are correct.
    Message[302] C:\WINDOWS\BUREAU\LCD877\LCD877.ASM 334 : Register in operand not in bank 0.  Ensure that bank bits are correct.
    Message[302] C:\WINDOWS\BUREAU\LCD877\LCD877.ASM 345 : Register in operand not in bank 0.  Ensure that bank bits are correct.
    Message[302] C:\WINDOWS\BUREAU\LCD877\LCD877.ASM 637 : Register in operand not in bank 0.  Ensure that bank bits are correct.
    Message[302] C:\WINDOWS\BUREAU\LCD877\LCD877.ASM 639 : Register in operand not in bank 0.  Ensure that bank bits are correct.
    Message[302] C:\WINDOWS\BUREAU\LCD877\LCD877.ASM 640 : Register in operand not in bank 0.  Ensure that bank bits are correct.
    Message[302] C:\WINDOWS\BUREAU\LCD877\LCD877.ASM 643 : Register in operand not in bank 0.  Ensure that bank bits are correct.

  22. #21
    freepicbasic

    Re : 16f84 à 16f877

    C'est un Warning , il dit de vérifier si tu as bien sélectionné la bonne bank.
    Donc à vérifier !
    A+, pat

  23. #22
    sdow

    Re : 16f84 à 16f877

    pour les warning c'est ok

    mais mon code ne marche pas toujours

  24. #23
    DavidDB

    Re : 16f84 à 16f877

    Dans l'Init du LCD, il faut faire une routine supplémentaire presque identique à "LCDPUTCMD" à la différence près qu'elle utilise des tempos à la place d'un test de busy flag.

    Pour pat :

    Le premier délai de la routine initiale ne sert qu'a la stabilisation de la tension d'alimentation du LCD.

    David.

  25. #24
    sdow

    Re : 16f84 à 16f877

    c'est bizzar je viens encore d' esayer avec 16f84 tout marche .

    mais avec 877 rien . il me semble que le probleme est dans les registre de init

    mais ou ????

  26. #25
    sdow

    Re : 16f84 à 16f877

    est-ce-que quelquen a programmé un lcd avec 877. est-ce-qui il peut m'aider

    S"V"P

  27. #26
    DavidDB

    Re : 16f84 à 16f877

    Salut,

    Regarde la page 45 du datasheet en annexe, et tu verras que l'init du LCD dans ton programme est incohérente au niveau de BF...

    http://www.sparkfun.com/datasheets/LCD/HD44780.pdf

    Sinon, pour un programme standard de LCD, regarde sur le site de Bigonoff, il y a un exemple dans les réalisations pratiques.

    David.

  28. #27
    RISC

    Re : 16f84 à 16f877

    sdow,

    Regarde sur cette page les fichiers samples de la carte PICDEM 2 PLUS :
    http://www.microchip.com/stellent/id...&part=DM163022

    Cette carte comporte un afficheur LCD avec un controleur HD44780 (2 lignes de 16 caractères).

    Des fichiers d'exemples sont fournis pour le PIC16F877 pour piloter en autre l'afficheur LCD.

    Tu peux télécharger les fichiers qui comportent le source en assembleur et l'adapter à ton système (les ports sont peut etre différents).

    Le schéma de la carte PICDEM 2 PLUS se trouve sur le user guide en téléchargement.

    a+

Discussions similaires

  1. servo et pic 16f877
    Par invitecb40bc0e dans le forum Électronique
    Réponses: 7
    Dernier message: 11/10/2009, 08h42
  2. pb prog CC5X 16F877
    Par invite4d22160b dans le forum Électronique
    Réponses: 1
    Dernier message: 01/11/2007, 08h10
  3. keypad 16f877
    Par sdow dans le forum Électronique
    Réponses: 1
    Dernier message: 15/09/2007, 20h15
  4. 16f877>16877A
    Par inviteaf1042fc dans le forum Électronique
    Réponses: 1
    Dernier message: 29/07/2007, 20h45
  5. Bootloader PIC 16F877
    Par azertylr dans le forum Électronique
    Réponses: 7
    Dernier message: 30/12/2005, 21h30
Découvrez nos comparatifs produits sur l'informatique et les technologies.