transfer a string from ROM to an array


Closed Thread
Results 1 to 40 of 45

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: transfer a string from ROM to an array

    how are you looking at the pgm memory , I think something is not right

    for me the da and data directives produce exactly the same result , I left the da directive in, thinking I might try the code on a pic16f1825 for a learning experience , for 7 bit ascii data either will do (pic 18's can store 2x8 bit ,pic 16's 2x7bit )

    the relevant listings
    Code:
    0
    0013E 6854 7369 6920 00199  data "This is a string",0
              2073 2061 7473 
              6972 676E 0000
    Code:
    00013E 6854 7369 6920 00199  da "This is a string",0
                2073 2061 7473 
                6972 676E 0000

  2. #2
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: transfer a string from ROM to an array

    Found the problem.

    I have a string like this:

    say "hello"

    I use this format do declare it, the same format I was using with arraywrite

    Code:
    @ da "say",34,"hello",34,0
    The result in program memory is that before each char 34 is added a char 00
    If I use "db" instead the result is correct.
    The pdf I linked before says that "da" is not for PIC18

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: transfer a string from ROM to an array

    where ?
    da – Data ASCII.
    Generates a packed 14-bit number representing two 7-bit ASCII characters.

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: transfer a string from ROM to an array

    this works
    @ da "say \"Hello\"\0"

  5. #5
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: transfer a string from ROM to an array

    Quote Originally Posted by richard View Post
    where ?
    da – Data ASCII.
    Generates a packed 14-bit number representing two 7-bit ASCII characters.
    4.14 da – STORE STRINGS IN PROGRAM MEMORY (PIC12/16 MCUs)

    Funny, but if you try it you'll see the unwanted 00 added

    db is ok

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: transfer a string from ROM to an array

    db is definitely an easier way to pack a mixed string data statement like "say",34,"hello",34,0 . funny I could never see the point of db until now

  7. #7
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: transfer a string from ROM to an array

    PICs always have hidden surprises ....

    Ok, understood also indirect addressing now, thanks for your patience :-)

  8. #8
    Join Date
    Aug 2004
    Posts
    64


    Did you find this post helpful? Yes | No

    Default Re: transfer a string from ROM to an array

    Hi:
    I use this routine to send eeprom stored msg's to display LCD.
    It can be modified to send then to a string...
    I hope this helps...
    '************************************************* ***************
    'USED VARS:

    SDAT VAR PORTD.1 'I2C EEPROM DATA 'ADJUST TO USED PINS AND
    SCLK VAR PORTD.0 'I2C EEPROM CLOCK 'MAKE THEM INPUTS IN USED TRIS REG.
    CHAR VAR BYTE
    SLAVE VAR BYTE
    EEADDR VAR WORD
    SLAVE = $A0 'EEPROM SLAVE ADDRESS
    '***** SUB TO DISPLAY MSGS STORED IN EEPROM ****************
    MSG_DISP:
    GOSUB CLRDISP 'CLEAR SCREEN
    MSG:
    LEENXT: I2CREAD SDAT,SCLK,SLAVE,EEADDR,[CHAR] 'SIN CLEAR
    IF CHAR => $80 THEN
    LCDOUT $FE,CHAR
    GOTO INCADD
    ENDIF
    IF CHAR <> 0 THEN
    LCDOUT CHAR
    INCADD: EEADDR = EEADDR + 1
    GOTO LEENXT
    ENDIF
    RETURN
    '************************************************* *************
    'TO CALL THE ROUTINE:
    'SET EEPROM ADDRES:
    'YOUR STRING CAN HAVE ANY LENGTH AND MUST BE TERMINATED WITH A NULL CHAR
    '"00"
    '*********************************************
    EEADDR = $0350 'WHEREVER YOUR STRING STARTS
    GOSUB MSG_DISP
    '*********************************************
    ' YOU MUST USE AN EEPROM WITH WORD ADDRESS (25LC32A,OR BIGGER)
    'PROGRAMM YOUR EEPROM WITH MSGS ENDED WITH 00 (NULL) AND TAKE NOTE OF
    'THE START ADDRESSES.
    'AND THATS ALL...
    Greetings...
    Ruben de la Pena V.

Similar Threads

  1. String of characters(array) to decimal value
    By tacbanon in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 20th June 2012, 14:30
  2. Replies: 3
    Last Post: - 3rd December 2011, 22:48
  3. Array of string to send with TX int ?
    By amgen in forum General
    Replies: 18
    Last Post: - 18th August 2011, 16:56
  4. How to send a string with another string inside it?
    By financecatalyst in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 13th May 2011, 17:11
  5. Manipulation of string array
    By Benny007 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 23rd April 2008, 20:50

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts