HSERIN each character cost 3 pgm words


Closed Thread
Results 1 to 12 of 12
  1. #1
    Join Date
    Jan 2007
    Posts
    39

    Default HSERIN each character cost 3 pgm words

    Hello,
    I am trying to write simple Web server with 16F648A. This PIC has 4096 pgm words. I have discoverred very uneffective storing of characters in program memory using HSEROUT.

    e.g.

    HSEROUT ["a"] 'cost 3 pgm words
    HSEROUT ["aa"] 'cost 6 pgm words

    So each new character cost 3 pgm words!
    So if I have 4096 pgm memory, I can use in my program just 1000 characters and that's it.
    Anyone has any idea how to use the strings with HSEROUT in a better way?

    Thanks for any idea, i need to use at least 2K of HTML code + program code.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by boban View Post
    HSEROUT ["a"] 'cost 3 pgm words
    HSEROUT ["aa"] 'cost 6 pgm words
    So each new character cost 3 pgm words!
    So if I have 4096 pgm memory, I can use in my program just 1000 characters and that's it.
    Anyone has any idea how to use the strings with HSEROUT in a better way?
    Each new character takes 3 words...yes...
    One to set the bank register to where the character is located
    One to load the character into the working register
    One to load that same character from the working register over to the serial output register

    This might help...
    http://www.picbasic.co.uk/forum/show...=macro+hserout

  3. #3
    Join Date
    Jan 2007
    Posts
    39


    Did you find this post helpful? Yes | No

    Default Compiler problem

    Hello Skimask,
    first thanks for the reply. I have tried http://www.picbasic.co.uk/forum/show...=macro+hserout seems it is a solution. I have played with it yesterday. But seems I have a problem with the compiler. If I have tried to compile my program for 16F877 it was successfully compiled. But if I have tried to compile it for 16F648A I have the following error:

    Message[306] E:\PICDEVELOPMENTTOOLS\PBP\PBP246\PBPPIC14.LIB 696 : Crossing pageboundary -- ensure page bits are set.
    Message[306] E:\PICDEVELOPMENTTOOLS\PBP\PBP246\PBPPIC14.LIB 624 : Crossing pageboundary -- ensure page bits are set.
    Error[113] E:\PICDEVELOPMENTTOOLS\PBP\PBP246\PBPPIC14.LIB 428 : Symbol not previously defined (EEADRH)
    Error[113] E:\PICDEVELOPMENTTOOLS\PBP\PBP246\PBPPIC14.LIB 442 : Symbol not previously defined (EEADRH)
    Error[113] E:\PICDEVELOPMENTTOOLS\PBP\PBP246\PBPPIC14.LIB 456 : Symbol not previously defined (EEADRH)
    Error[113] E:\PICDEVELOPMENTTOOLS\PBP\PBP246\PBPPIC14.LIB 470 : Symbol not previously defined (EEADRH)
    Error[113] E:\PICDEVELOPMENTTOOLS\PBP\PBP246\PBPPIC14.LIB 797 : Symbol not previously defined (EEADRH)
    Error[113] E:\PICDEVELOPMENTTOOLS\PBP\PBP246\PBPPIC14.LIB 428 : Symbol not previously defined (EEDATH)
    Error[113] E:\PICDEVELOPMENTTOOLS\PBP\PBP246\PBPPIC14.LIB 442 : Symbol not previously defined (EEDATH)
    Error[113] E:\PICDEVELOPMENTTOOLS\PBP\PBP246\PBPPIC14.LIB 456 : Symbol not previously defined (EEDATH)
    Error[113] E:\PICDEVELOPMENTTOOLS\PBP\PBP246\PBPPIC14.LIB 470 : Symbol not previously defined (EEDATH)
    Error[113] E:\PICDEVELOPMENTTOOLS\PBP\PBP246\PBPPIC14.LIB 795 : Symbol not previously defined (EEDATH)

    Seems it is a bug of PBP lib no?

    Boban

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by boban View Post
    If I have tried to compile my program for 16F877 it was successfully compiled. But if I have tried to compile it for 16F648A I have the following error:
    ......
    Seems it is a bug of PBP lib no?
    Boban
    No it doesn't.
    Check the datasheets.
    '877a has an eeadrh register, '648 doesn't.
    '877a can read/write it's own eeprom AND flash program memory.
    '648 can only read/write it's own eeprom.

  5. #5
    Join Date
    Jan 2007
    Posts
    39


    Did you find this post helpful? Yes | No

    Default

    Ahhh ****, ok, so it means, that I cannot use this trick to save the strings to program flash.

    OK, great, so is there any way, how could I store and use the strings more efficiently ?

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by boban View Post
    Ahhh ****, ok, so it means, that I cannot use this trick to save the strings to program flash.

    OK, great, so is there any way, how could I store and use the strings more efficiently ?
    Store it in internal eeprom and read it out from there...or store it in external eeprom...or...or...or...

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by boban View Post
    OK, great, so is there any way, how could I store and use the strings more efficiently ?
    For PIC's that can't access their own flash, the next best option is POKECODE/PEEKCODE, which will work on any chip.

    http://www.picbasic.co.uk/forum/showthread.php?p=51931

    Notice how the "TOO LOW " and "TOO RICH" strings are stored.
    And how it's displayed in the ShowMsg: routine. Just change the LCDOUT to HSEROUT.

    It uses 1 word per character stored.
    Plus about 30 words for the retreival code.
    <br>
    DT

  8. #8
    Join Date
    Jan 2007
    Posts
    39


    Did you find this post helpful? Yes | No

    Default Moved to 16F916 and it's working

    Hello, Thanks Darrel and Skimask, I had in my pocket one 16F916 where this trick to store two chars to one pgm word is working well. I was able to rapidly decrease my code space. 1.5K instead of 4K. I will also test this POKECODE/PEEKCODE on my 16F648.
    Thanks both of you...

    I think, the EEPROM is not solution it has just 256 bytes and I need to store there some data and also external EEPROM will complicate the design. But maybe for the storage of lot of html code this could be the solution.

    My webserver with Lantronix Direct port is working pretty well now. I have even some space to make the html more nicer )))

    Boban

    P.S. I am now thinking about the feature to have the possibility to store the hlml pages during runtime - kind of firmware update. My idea is to reserve the space in code memory like put there spaces and via webserver to have the service to upgrade the html code during the runtime. But I must check the assemler if it is possible to write to program code during the execution. Have no clue....

  9. #9
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by boban View Post
    I think, the EEPROM is not solution it has just 256 bytes and I need to store there some data and also external EEPROM will complicate the design. But maybe for the storage of lot of html code this could be the solution.........
    P.S. I am now thinking about the feature to have the possibility to store the hlml pages during runtime - kind of firmware update. My idea is to reserve the space in code memory like put there spaces and via webserver to have the service to upgrade the html code during the runtime. But I must check the assemler if it is possible to write to program code during the execution. Have no clue....
    Would be a load easier just to add an external 24LCxxx serial eeprom and use that. 2 wires, I2Cread/I2Cwrite... Not much code space wasted, lots of room for add-ons...
    Not much code space in a '916 as you're well aware I'm sure. Start adding HTML code as data in the program space, and you'll be out of space in no time flat...

  10. #10
    Join Date
    Jan 2007
    Posts
    39


    Did you find this post helpful? Yes | No

    Default 16f916

    Hello, the external eeprom will complicate the design, and if you are writting effectively html you could store almost 10 K of HTML = 5 K words and remaining 3 k of code, I have managed to store what I wanted. I have just little bit fighted with the fact, that if you are doing something like
    @ da "abcd",10,"efgh",0 the da will pack 0 and 10 and it caused the cutting of my Strings. So I have decided to put to the end of each string not 0 but 0x7F and I have modified little bit the code to skip 0 byte and use 7F as separator. And it is working pretty well!!! Thanks everyone for help!!!

    StringOut:
    ReadCode Addr, TwoChars
    Char = TwoChars >> 7
    if Char = $7F THEN StringDone
    if Char <> 0 then hserout [Char]
    Char = TwoChars & $7F
    if Char = $7F then StringDone
    if Char <> 0 then hserout [Char]
    Addr = Addr + 1
    goto StringOut
    StringDone:
    return

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


    Did you find this post helpful? Yes | No

    Default

    That'll work!

    Might use a few bytes for those extra 0's

    You can put the "Escape codes" in the string, and it won't use the extra bytes.

    @ da "abcd\nefgh",0

    Code:
    \a	Bell (alert) character		07
    \b	Backspace character		08
    \f	Form feed character		0C
    \n	New line character		0A
    \r	Carriage return character	0D
    \t  	Horizontal tab character	09
    \v	Vertical tab character		0B
    \\	Backslash			5C
    \?	Question mark character		3F
    \'	Single quote (apostrophe)	27
    \"	Double quote character		22
    \0OO	Octal number (zero, Octal digit, Octal digit)	
    \xHH	Hexadecimal number
    Might even be able to put the "Null terminator" in there too.

    @ da "abcd\nefgh\x00"

    But I haven't tried that yet.
    <br>
    DT

  12. #12
    Join Date
    Jan 2007
    Posts
    39


    Did you find this post helpful? Yes | No

    Thumbs up xHH versus 0xHH

    Hello Darrel, thanks a this helped I didn't know, taht I could use the escape sequences like in C or Java

Similar Threads

  1. Replies: 4
    Last Post: - 15th April 2009, 01:54
  2. HSERIN and STR - character encoding
    By boban in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 13th August 2008, 17:36
  3. Hserin, 1st character always lost!
    By Ioannis in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 5th June 2007, 12:49
  4. Someone help me to simplify this
    By thrix in forum General
    Replies: 4
    Last Post: - 21st February 2004, 05:01
  5. Help wanted..
    By thrix in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 17th February 2004, 23:44

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