String & WRITE


Closed Thread
Results 1 to 17 of 17

Thread: String & WRITE

Hybrid View

  1. #1
    Join Date
    Sep 2005
    Location
    Switzerland
    Posts
    46

    Default String & WRITE

    Hello everybody.
    Pls. I need yr. help.
    With HSerin I read a string coming from a serial port and I get this
    string "34567890".
    Now I'd like to store (with WRITE) into onchip eeprom starting
    from location 0 this string, after that the eeprom memory should look
    like this:
    34 56 78 90 FF FF FF FF ...............
    I tried several possible solution but I was not able to 'brake' in 4 parts
    the string.
    Any help will be appreciated.
    Thanks
    Lotondo

  2. #2
    egberttheone's Avatar
    egberttheone Guest


    Did you find this post helpful? Yes | No

    Default

    I don't really understand your question, but here is maybe the solution: if you want to store word sized variable's into the eeprom memory you have to split the word into 2 byte's you can use the variable.lowbyte and variable.highbyte command. When reading you do this procidure in reverse.

  3. #3
    Join Date
    Sep 2003
    Location
    Vermont
    Posts
    373


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Lotondo
    Hello everybody.
    Pls. I need yr. help.
    With HSerin I read a string coming from a serial port and I get this
    string "34567890".
    Now I'd like to store (with WRITE) into onchip eeprom starting
    from location 0 this string, after that the eeprom memory should look
    like this:
    34 56 78 90 FF FF FF FF ...............
    Are the numbers coming in as 34,56,78..... or are they coming in individually?

  4. #4
    Join Date
    Sep 2003
    Location
    Vermont
    Posts
    373


    Did you find this post helpful? Yes | No

    Default

    To pack single hex digits into a hex byte, just shift the first digit left four times, then add it to the second digit.

    Ron

  5. #5
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Default

    OK, I just try to make the situation clear...

    You receive 8 ASCII-Characters "3", "4", "5", "6", ....
    Then you want to pack 2 digits in 1 Byte and write them to the eeprom.

    Yust try:
    Chars Var byte[8] ;here are the 8 digits
    For I=0 to 3 ;generate 4 bytes
    ;cut off unused bits and pack 2 of them
    Dummy=(Chars[I<<1]<<4)|(Chars[(I<<1)+1] & $F)
    Write I,Dummy
    next I

    (Very quick and quite dirty!)
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi BigWumpus,

    I know you did it real quick, but I think something's missing.

    Dummy=((Chars[I<<1]-"0")<<4)|((Chars[(I<<1)+1]-"0") & $F)

    Darrel

  7. #7
    Join Date
    Sep 2005
    Location
    Switzerland
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Thanks for answering, I believe you got me the solution.
    I'll try and in case I'm not getting the correct result I'll
    come back to you.
    Regards
    Lotondo

  8. #8
    Join Date
    Dec 2017
    Posts
    4


    Did you find this post helpful? Yes | No

    Default Re: String & WRITE

    Although the topic is quite old I am interested to solve a similar problem for which will really appreciate your support / expertise.

    On short, I am receiving serially 16 ASCII-Characters, say "3", "B", "5", "A", "7", "F","1", "D", "2", "2", "4", "F","E", "E", "A", "6".

    Then I need to pack 2 digits in 1 Byte and write them to the EEPROM. The final result should be: 2B 5A 7F 1D 22 4F EE A6.
    Any clue or tip with regard to algorithm or conversion formula will be highly appreciated. Have a happy and prosperous New Year !

Similar Threads

  1. WRITE: One more PBP 2.60 Surprise ...
    By Acetronics2 in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 26th August 2009, 09:10
  2. Need the code to write to a memory
    By Hamlet in forum General
    Replies: 0
    Last Post: - 20th August 2007, 00:22
  3. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  4. Visual Basic 6 & Access 2000
    By Demon in forum Off Topic
    Replies: 33
    Last Post: - 7th September 2006, 04:39
  5. Storing Strings using the Write command
    By BobP in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st November 2005, 11:31

Members who have read this thread : 1

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