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] How to implement a string command syntax with PIC assembly

Status
Not open for further replies.

kemalkemal

Member level 1
Joined
Jan 27, 2013
Messages
38
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,672
Hi,
Fırst of all I am using PIC18f4520 , MPLABX and assembler. I want to use a serial port data plotter which I downloaded from Microchips site named "PIC Data Plotter". **broken link removed**
According to PIC Data Plotters user guide to configure the program and then to send data which is to be plotted you need to use a command syntax like this:
#NOP\r\n
Or another command from the guide is this:
#GS;3\r\n
The exact words about command syntax from help file is:
The first byte “#” is a marker of the GUI command. The ASCII command name follows the marker. All elements in the command using ASCII characters are divided by semicolon “;”. The command can have a few parameters. The “new line” sequence “\r\n” ends any command. If the parameters are in the binary format, the semicolon delimiter must be skipped after them. The byte size of the binary parameter is known and it allows parsing.
After i implement the command i will send it through USART module to serial comm port. I try this structure but didnt work
Code:
MOVLW 0x23 ;# 
MOVWF data_h
CALL P18_usart_send

MOVLW 0x4E ;N 
MOVWF data_h
CALL P18_usart_send

MOVLW 0x4F ;O 
MOVWF data_h
CALL P18_usart_send

MOVLW 0x50 ;P 
MOVWF data_h
CALL P18_usart_send

MOVLW 0x5C ;\
MOVWF data_h
CALL P18_usart_send 
 
MOVLW 0x72 ;r
MOVWF data_h
CALL P18_usart_send 
 
MOVLW 0x5C ;\
MOVWF data_h
CALL P18_usart_send
 
MOVLW 0x6E ;n
MOVWF data_h
CALL P18_usart_send

(P18_usart_send routine is my send routine and i do know it is working properly)
So my question: is my code structure to implement command #NOP\r\n right ? Or should i try something different?
Thanx in advance.
 

Hi,

I assume "\r" means "carriage return" which is a single byte with the value "0x0D"
And "\n" means "new line" which is a single byte with the value "0x0A"

Klaus
 
It worked. You are a life saver KlausST :) Thanx.
( One note if someone interested; After i change "\r" and "\n" with the right codes , I reversed the order of sent bytes because program accepts little endian data. Final and correct core :

Code:
MOVLW	0x0A		    ;\n
MOVWF	data_h
CALL	P18_usart_send    
   
MOVLW	0x0D		    ;\r
MOVWF	data_h
CALL	P18_usart_send      
   
MOVLW	0x50		    ;P		    
MOVWF	data_h
CALL	P18_usart_send    
   
MOVLW	0x4F		    ;O		    
MOVWF	data_h
CALL	P18_usart_send   
   
MOVLW	0x4E		    ;N		    
MOVWF	data_h
CALL	P18_usart_send    
   
MOVLW	0x23		    ;#		    
MOVWF	data_h
CALL	P18_usart_send
 

Hi,

I reversed the order of sent bytes because program accepts little endian data.
I doubt this. I´ve never seen a string that is sent in the wrong order.

Afaik. Little_endian and big_endian is mainly for storing mulibyte integer values in memory. (not 100% sure)

Klaus
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top