Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Mplab Editor Text Entry

Status
Not open for further replies.

fenderman

Member
Hi All,
This is probably a very fundametal question, but I've not found the answer yet !
I am using the MPLAB editor for assembler code entry, and was looking for an editor directive that allows for the entry of a text line.
I am writing a program for a 2 line by 16 character LCD display, and wish to entry the messages as 'strings' into to editor, instead of the MOVLW instruction, ie .
MESSAGE: <define string> "THE MESSAGE LINE"
where <define string> would be the assembler directive to produce a 16 byte character string.

I have scoured the MPLAB documentation and Microchip forum's (and this forum) but not found anything.

Any help would be appreciated.

Roy
 
Last edited:
hi,

Have you checked the MPLAB online help, under 'strings'

Dosnt da or data do what you want.:)
 
Last edited:
Hi Eric,

Thanks for the reply, had a look at the 'String' data function as suggested,
But the format of :-

LABEL: DATA "1234567890123456"
only seemed to produced a single character.

However, the second method of character seperation :-
LABEL: DATA '1','2','3','4','5','6','7','8','9','0','1','2','3','4','5','6'
did produce the correct data string in the memory.

Thanks again for the pointer.

Roy
 
Last edited:
Hi Eric,

Thanks for the reply, had a look at the 'String' data function as suggested,
But the format of :-

LABEL: DATA "1234567890123456"
only seemed to produced a single character.

However, the second method of character seperation :-
LABEL: DATA '1','2','3','4','5','6','7','8','9','0','1','2','3','4','5','6'
did produce the correct data string in the memory.

Thanks again for the pointer.

Roy

hi Roy,
This is a code fragment of the method I use.:)

Code:
Msg2LCD	macro	LcdMsg, Line  
	movlw	Line
	call	CMD2LCD           
	movlw	LOW LcdMsg    
	movwf	PNTRL         
	movlw	HIGH LcdMsg   
	movwf	PNTRH            
	call	Lcd_Msg
	endm

Msg2LCD	Msg1,	LINE1

	;message to LCD 
Lcd_Msg: 
	clrf	Cntr0
NxtChr:
	movfw	Cntr0
	call	SegAddr
	iorlw	0x00
	btfsc	STATUS,Z
	return; goto	EOMSG1
	call	CHR2LCD
	incf	Cntr0,F
	goto	NxtChr
EOMSG1:
	return

SegAddr: 
	movwf	TmpBfr
	movf	PNTRH,W
	movwf	PCLATH
	movf	PNTRL,W
	addwf	TmpBfr,W
	btfsc	STATUS,C
	incf	PCLATH,F
	movwf	PCL

Msg1:
	dt	"LCD Testing....",0
Msg2: 
	dt	"Opt2 PIC 16F877",0
Msg3: 
	dt	"LCD Line #3 Msg",0
Msg4: 
	dt	"This is #4",0
 
Eric,

Thanks for that, It does work perfectly with the 'DT' directive, I was using the 'DA' / 'DATA' directive.

Incidentaly, I am using the PIC16F648A just as an LCD message handler holding around 200 pre-defined messages that will be 'called' up from a remote system just telling it which meassage and which line (upper/lower) to display it on.

Thanks for your help.

Roy
 
If you switch to the pin compatible 16F88 then you can use the da directive to place two ascii characters per location and use the read flash ability to access it. It also runs twice as fast if using the internal oscillator.

Mike.
 
Cheers Mike,

I'll have a look at that ... its just that I have dozens of the 16F648A's left over that I purchased for another project that is now completed, and was just using these up on this project to get rid of the stock ...

Roy
 
I use a method similar to Eric's but I prefer to store the string tables in-line with my code. Just seems more intuitive to me.

The string tables can be longer than 256 bytes and can straddle 256 byte boundaries?

Regards, Mike

Code:
;
;  example usage of the "PutStr" macro in your program
;
        movlw   Line1+4         ; line 1, tab 4
        call    LcdCmd          ;
        PutStr  "this is line 1"
        movlw   Line2+4         ; line 2, tab 4
        call    LcdCmd          ;
        PutStr  "this is line 2"
;
Code:
;******************************************************************
;
;  PutStr macro - print a string to the LCD
;
PutStr  macro   str             ;
        local   String, Print
        movlw   low String      ;
        movwf   PTRL            ;
        movlw   high String     ;
        movwf   PTRH            ;
        goto    Print           ;
String  dt      str,0
Print   call    PutString       ; print string
        endm
;
;******************************************************************
Code:
;******************************************************************
;
;  PutString - setup PTRL and PTRH to string address before entry
;            - string must be terminated with a 0 byte
;
PutString
        call    GetTable        ; get a table character           |B0
        andlw   b'11111111'     ;                                 |B0
        btfsc   STATUS,Z        ; a 00 byte, last character?      |B0
        return                  ; yes, return                     |B0
        call    LcdDat          ; output char                     |B0
        incfsz  PTRL,F          ; increment pointer               |B0
        goto    PutString       ;                                 |B0
        incf    PTRH,F          ;                                 |B0
        goto    PutString       ;                                 |B0
;
GetTable
        movf    PTRH,W          ;                                 |B0
        movwf   PCLATH          ;                                 |B0
        movf    PTRL,W          ;                                 |B0
        movwf   PCL             ;                                 |B0
;
;******************************************************************
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top