+ Post New Thread
Results 1 to 6 of 6
  1. #1
    Member level 1
    Points: 749, Level: 5

    Join Date
    Dec 2009
    Posts
    36
    Helped
    0 / 0
    Points
    749
    Level
    5

    using dt directive to write text string, pic 16f

    I downloaded this code for 3310 LCD
    hardware
    I really don't completely unerstand the dt directive. There are some text stringss just before the main loop
    Code:
    message	dt "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 @#$%&/()*+-",0xFD
    
    continua	;-----apunta a una posicion grafica del LCD donde empezar a escribir
    	
    		movlw	.0		;Y address
    		call	Y_address
    		movlw	.0		;X address
    		call	X_address
    
    		movlw	message	;<---- poner aqui la etiqueta del mensaje PCL-LSB
    		movwf	rotulo		;direcciona al mensaje que se quiere visualizar	
    		call	lee_rotulo
    Main ; main loop starts here
    this is the subroutine to write the string
    Code:
    ;############# lectura de la flash de programa en tiempo de ejecucion #######################
    lee_rotulo	movf	rotulo,W	;carga el vector donde apunta la etiqueta del mensaje		
    		bsf	STATUS, RP1	;
    		bcf	STATUS, RP0	;Banco 2
    		movwf	EEADR
    		movlw	0x00		;util si los mensajes estan en otra pagina de memoria
    		movwf	EEADRH
    		bsf	STATUS,	RP0	;banco 3
    		bsf	EECON1,EEPGD	;puntero a codigo de programa
    		bsf	EECON1,RD	;inicia la lectura
    		nop			;espera 2 nops para concluir la lectura
    		nop			;(obligatorio)
    		bcf	STATUS, RP0	;banco 2
    		movf	EEDATA, W	;byte bajo
    		bcf	STATUS, RP1	;banco 0
    		movwf	caracter
    		bsf	STATUS, RP1	;banco 2
    ;		movf	EEDATH, W	;byte alto
    ;		movwf	DATAH
    		bcf	STATUS, RP1	;banco 0
    		
    		movlw 	0xFD
    		subwf	caracter,W
    		btfsc	STATUS,Z
    		return			;finaliza la lectura
    		
    		call	pinta_letra
    		
    		incf	rotulo,f
    		goto 	lee_rotulo
    The problem is, when I move the text string for example to the end of the main loop, it doesn't work. although it is on the same page, I get no stack overflow error in Proteus, but only 1-2 random characters are displayed. How can I move the strings to other place and still have a working code?

    •   Alt15th June 2011, 16:58

      advertising

        
       

  2. #2
    Advanced Member level 5
    Points: 23,580, Level: 37

    Join Date
    May 2009
    Location
    Prime Meridian
    Posts
    2,803
    Helped
    797 / 797
    Points
    23,580
    Level
    37

    Re: using dt directive to write text string, pic 16f

    Hi,

    The lee_rotulo seems to be using eeprom, though not sure why without translating / understanding all that code.
    The DT is similar to a lookup table and just a means of holding the data you want to display.
    Unlike a conventional 2x16 lcd where the pic sends ascii characters to it, the nokia /glcd needs the message text to be broken down and converted into pixels before being send out via spi.

    Its a long time since i coded the 16Fs but think the you must keep your tables at the beginning of the main code, somthing like it must be withing a 256 byte boundary - see this link for more info on 16F tables.

    Simple answer to your question is just keep the dt messages where they are for now.

    using pic16f877 need help on look up table


    1 members found this post helpful.

    •   Alt15th June 2011, 21:25

      advertising

        
       

  3. #3
    Member level 1
    Points: 749, Level: 5

    Join Date
    Dec 2009
    Posts
    36
    Helped
    0 / 0
    Points
    749
    Level
    5

    Re: using dt directive to write text string, pic 16f

    Thanks for answer.
    One thing about this code I don't understand. When usually dt direcrive is used in lookup tables and the table is called with a "call" instruction, then here is just movlw "string label" instruction. How can the whole string fit into W register???? Does it? or the program returns to the string repeatedly to get the values?

    All the characters are defined with dt diretives and they are at the end of the code. Here, a Call instruction is used to accsess dt data. Maybe I should also use call instruction instead?



    •   Alt15th June 2011, 22:40

      advertising

        
       

  4. #4
    Advanced Member level 5
    Points: 23,580, Level: 37

    Join Date
    May 2009
    Location
    Prime Meridian
    Posts
    2,803
    Helped
    797 / 797
    Points
    23,580
    Level
    37

    Re: using dt directive to write text string, pic 16f

    Hi,

    , then here is just movlw "string label" instruction. How can the whole string fit into W register????

    Only had time to have a quick look at the code again.

    In the Main code you have this -

    Code:
    movlw	mensaje2	;<---- poner aqui la etiqueta del mensaje PCL-LSB
    		movwf	rotulo		;direccina al mensaje que se quiere visualizar	
    		call	lee_rotulo
    movlw mensaje2 does not try to load the whole message, movLW loads the memory address of the start of mensaje2. - the clue is in the comment ; -- PCL Least Significant Byte

    If you single step though the code you will see that lee-rotulo uses the lsb to set up a Flash memory read of the message data, if I'm correct.
    Towards the end of the routine it checks to see if the last byte of the message was the 'terminator' 0xFD, if not it sends out the current message bye by the 'call pinta_letra' then Increments the address, ' rotulo' and reads the next message byte.


    1 members found this post helpful.

  5. #5
    Member level 1
    Points: 749, Level: 5

    Join Date
    Dec 2009
    Posts
    36
    Helped
    0 / 0
    Points
    749
    Level
    5

    Re: using dt directive to write text string, pic 16f

    yes now I see. The High address(EEADRH) is always cleared in "lee_rotulo" subroutine. Now before I load "lee_rotulo" I also read high string label
    Code:
    movlw high mensaje2
    and place it in EEADRH, now I can read data that is located over the 256 byte limit. Next thing to do is to place all the data on another page, hope it's not too dificult.



  6. #6
    Member level 1
    Points: 749, Level: 5

    Join Date
    Dec 2009
    Posts
    36
    Helped
    0 / 0
    Points
    749
    Level
    5

    Re: using dt directive to write text string, pic 16f

    As it turns out I can place the strings anywhere in the code I want, on any page, very nice. Now I got plenty of memory to store many screenfull of text, and it is much easyer than call instruction and then having to mess around with PCLATH register to point to the right page.
    Thanks alot



+ Post New Thread
Please login