Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] using dt directive to write text string, pic 16f

Status
Not open for further replies.

tarts

Member level 2
Joined
Dec 13, 2009
Messages
43
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,615
I downloaded this code for 3310 LCD
**broken link removed**
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?
 

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.

https://www.edaboard.com/threads/69866/
 
  • Like
Reactions: tarts

    tarts

    Points: 2
    Helpful Answer Positive Rating
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?
 

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.
 
  • Like
Reactions: tarts

    tarts

    Points: 2
    Helpful Answer Positive Rating
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.
 

As it turns out I can place the strings anywhere in the code I want, on any page:-D, 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
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top