Best way to store text in a pic


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2007
    Location
    Denmark
    Posts
    28

    Question Best way to store text in a pic

    Hello fellow PBP'ers, I'm currently working on a project where I need to display many text lines in a LCD.

    The text outputs depend on the situation, say:

    if the count reaches 100 I'll display: "Good Morning, blah blah blah"

    then when the count reaches 150, it'll display: "good afternoon, blah blah"

    and so on..
    I want my program to be able to give many text strings..

    Suppose I'm using a pic 16f887,what is the best way to save space or to do this?

    I was thinking about doing many if...then's but that will probably eat my pic's memory in no time.
    I'll appreciate any piece of advice, thanks!

    WoZ

  2. #2
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default Maybe like this....

    Hi

    Maybe you can use an external EE-prom for your text strings. 24LC512 using I2C is a very cheap and simple way. Then you can use the PIC for program code and the EE-prom for text messages. This way will also allow you to change the text without having to recompile every time.



    /me

  3. #3
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    966


    Did you find this post helpful? Yes | No

    Smile

    This is how I do it

    Code:
    prn_SetDate:       PokeCode "Date changed",0
    prn_SetTime:       PokeCode "Time changed",0
    prn_LogPrinted:    PokeCode "Log printed",0
    prn_SafeClosedByMaster: PokeCode  "Key interlock cleared by master",0
    
    ASM
    GetAddress macro Label, Wout       ; Returns the Address of a Label as a Word
        CHK?RP Wout
        movlw low Label
        movwf Wout
        movlw High Label
        movwf Wout + 1
        endm
    ENDASM
    Address         var     word
    
    '----snip------
        ' This is how to use it
        ' Prt_puts uses the Variable Address to print the contents pointed at by it
        @ GetAddress _prn_SetDate, _Address ;macro from this site
        gosub Prt_puts                                 ; put the string to printer
    '----snip------
    
    ' Print an ASCIIZ string
    ' Input - Address points to the string
    Prt_puts:
      repeat
        peekcode Address, gr[0]                   ' gr[0] is a byte sized user register
        if gr[0] then 
          gosub Prt_putc                             ' print 1 character
          Address = Address+1
        endif
      until gr[0]=0                                     ' print till end of string '0'
      return
    Hope this helps

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Variant of the above

    STRINGS - How to store and retrieve strings in Code Space
    http://www.pbpgroup.com/modules/wfse...p?articleid=10

    which is also explain/discussed + few variant & mods

    Embedded Strings in your Code Space
    http://www.picbasic.co.uk/forum/show...ight=codespace
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. SMS via pic
    By kenandere in forum GSM
    Replies: 15
    Last Post: - 10th March 2010, 10:00
  2. Replies: 67
    Last Post: - 8th December 2009, 02:27
  3. assembly in Pic
    By lerameur in forum Off Topic
    Replies: 11
    Last Post: - 1st May 2008, 20:06
  4. Help with sending text file from pic
    By isaac in forum Serial
    Replies: 6
    Last Post: - 15th August 2006, 20:01
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

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