Menu

string issue

sfyris
2013-05-12
2016-05-10
  • sfyris

    sfyris - 2013-05-12

    Hello there. Why the code i wrote for writing a string in the EEPROM of a 12F675 puts zeros instead of the last chars of the string? (look at the attached picture)

     
  • Dimitris Katsaounis

    Same problem in 18f2550 :(

     
  • sfyris

    sfyris - 2013-06-10

    Hi there again. Something has changed in the forum and the image doesn't fit in the window. Right click on it and select show image to see the full one. Thank you

     
  • Anobium

    Anobium - 2015-12-05

    @all. This works. Is there an issue?

    ~~~~~
    #chip 12f675

    dim strline as string
    strline = "abcdefghijklmopqrstuvwxyz"
    
    firstchar = 0
    EPRead streepromaddr, firstchar
    
    for gen_counter = 1 to strline(0)
        EPWrite streepromaddr, strline(gen_counter)
      streepromaddr++
    next
    

    ~~~~

     

    Last edit: Anobium 2015-12-05
  • sfyris

    sfyris - 2015-12-05

    I will try and be back...but....can be different the streepromaddr++ from streepromaddr = streepromaddr + 1? Because except from the if statement I don't see any other difference from my code (btw the if statement is needed, I can not skip it in my application)

     

    Last edit: sfyris 2015-12-05
  • Anobium

    Anobium - 2015-12-05

    Do try. Let us know.

     
  • sfyris

    sfyris - 2015-12-05

    Ok I tryed but not worked. And additionaly I am now with a EEPROM full of unterminated strings :)

     
  • Anobium

    Anobium - 2015-12-05

    please post your code that shows the issue. Please post working code. You don't have to post all your code just enough to compile and enable us to understand the root cause.

    Cheers

     
  • sfyris

    sfyris - 2015-12-06

    What do you mean Anobium? I tryed the code you suggested before but had the same issue. This is a working code allone and nothing more. In the attachment is one file with the asm code and one with hex code

     

    Last edit: sfyris 2015-12-06
  • Anobium

    Anobium - 2015-12-06

    Sorry, my error.

    Can you please post the code you are using? I think my same code has an error. :-( As streepromaddr was not initialised to zero.

        #chip 12f675
    
        dim strline as string
        strline = "abcdefghijklmopqrstuvwxyz"
    
        streepromaddr = 0
        EPRead streepromaddr, firstchar
    
        for gen_counter = 1 to strline(0)
            EPWrite streepromaddr, strline(gen_counter)
          streepromaddr = streepromaddr + 1
        next
    
     
  • sfyris

    sfyris - 2015-12-06

    Ok tryed with the correction of the initialisation. Now EEPROM is not full of strings but the issue with 0s in the end remains :P

     
  • sfyris

    sfyris - 2015-12-06

    ......and here the new asm and hex files

     
  • Anobium

    Anobium - 2015-12-06

    Can you post your gcb source file please?

     
  • sfyris

    sfyris - 2015-12-06

    yes

     
  • Anobium

    Anobium - 2015-12-06

    Please send me a personal message. I will send you the latest build I recommend not posting your email address as a public posting.

     
  • sfyris

    sfyris - 2015-12-06

    Ok got the message. Will check it tomorrow. Thanks for attention Anobium

     
  • Anobium

    Anobium - 2015-12-07

    The code below works. When defining string variables the string length defaults to the following rules and the RAM constraints of a specific chip.
    · 10 bytes for chips with less than 16 bytes of RAM.
    · 20 bytes for chips with 16 to 367 bytes of RAM.
    · 40 bytes for devices with more RAM than 367 bytes
    · For chips that have less RAM then required RAM to support the strings will be NOT be allocated. -

    Sample working code

      #chip 12f675
    
      dim strline as string * 26
      strline = "abcdefghijklmnopqrstuvwxyz"
    
      streepromaddr = 0
      EPRead streepromaddr, firstchar
    
      for gen_counter = 1 to strline(0)
        EPWrite streepromaddr, strline(gen_counter)
        streepromaddr = streepromaddr + 1
      next
    

    Provides from an EEPROM read.

    61  62  63  64  65  66  67  68  a   b   c   d   e   f   g   h
    69  6A  6B  6C  6D  6E  6F  70  i   j   k   l   m   n   o   p
    71  72  73  74  75  76  77  78  q   r   s   t   u   v   w   x
    79  7A  FF  FF  FF  FF  FF  FF  y   z   .   .   .   .   .   .
    
     

    Last edit: Anobium 2015-12-07
  • sfyris

    sfyris - 2015-12-08

    Well gentlemen once again and after lots of mails, anobium proved how trustworthy is his product (GCGB), how helpful are his advices and what a deep knowledge is hiden in these. Anobium (and Kent) very very thanks for all of your time, keep going giving us your best and I am sure some day somehow you will get good results from this effort. I think the subject was covered and you can lock it now.

     
  • Anobium

    Anobium - 2015-12-08

    Cheers - but not my product but Hughs'.

    Anobium

     
  • sfyris

    sfyris - 2015-12-08

    :) ok sorry Hughs

     
  • Dave B

    Dave B - 2016-05-10

    This answered a question I was going to ask before i asked it. So many thanks form me, as well. And hugs to Hughs, lol!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.