memory full


+ Reply to Thread
Results 1 to 3 of 3

Thread: memory full

  1. #1
    Join Date
    Jul 2005
    Location
    The Netherlands
    Posts
    41

    Default memory full

    Hi all,

    I have a application with the 16F882 and have add some data. But the memory is run over.
    The '882 = 2048 words, "883 is only 4096 words.

    I drive a LCD (1602) RS485 and some LEDs and buttons. Not really exciting.

    But, I have 30 Hub's (0 to 29) to Open and Close and show on the LCD.

    All 30 Open and Close strings are different.


    After 8 Hub's in the program the memory ("882) runs out. Any advice?


    Hub_ID = 0 ' Hub Open

    high EN_RS485 ' Enable RS485
    pause 5
    hserout [0,2,0,16,67,45,255,15,222,3] ' Bus open
    LCDOut $fe,$C0,"Hub ",dec Hub_ID, " is Open "
    pause 5 ' Wait for last byte out
    low EN_RS485 ' Disable RS485

    pause 1000

    high EN_RS485 ' Enable RS485
    pause 5
    hserout [0,2,0,16,67,47,255,15,220,3] ' Bus close
    LCDOut $fe,$C0,"Hub ",dec Hub_ID, " is Close "
    pause 5 ' Wait for last byte out
    low EN_RS485 ' Disable RS485

    pause 1000


    ' Do next Hub

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    974


    Did you find this post helpful? Yes | No

    Default Re: memory full

    Are you repeating the same code 30 times since the messages differ? Then, possibly, you could be facing this issue as strings gobble up memory pretty fast.

    I would look at the feasibility of building subroutines that take the hubid and printing out messages that would be/could be common. That will bring in some reduction.

    By your description, the picture is not entirely clear, so, I could be off on my diagnoses.

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,627


    Did you find this post helpful? Yes | No

    Default Re: memory full

    Yeah, lots of repeating code there...
    For starters, move the LCDOUT commands to a subroutine.
    Unless you're running HSEROUT at 150baud or something you can most likely remove the PAUSE 5 after LCDOUT since LCDOUT will take way more time to execute that what it takes the USART to spit out that last byte.

    Code:
    Main:
      Hub_ID = 0 ' Hub Open
    
      high EN_RS485 ' Enable RS485
      pause 5
      hserout [0,2,0,16,67,45,255,15,222,3] ' Bus open
      GOSUB ShowHubOpen
      low EN_RS485 ' Disable RS485
    
      pause 1000
    
      high EN_RS485 ' Enable RS485
      pause 5
      hserout [0,2,0,16,67,47,255,15,220,3] ' Bus close
      GOSUB ShowHubClosed
      low EN_RS485 ' Disable RS485
    
      pause 1000
    
    ' Do next Hub
    
    Goto Main
    
    ShowHubOpen:
      LCDOut $fe,$C0,"Hub ",dec Hub_ID, " is Open "
    RETURN
    
    ShowHubClosed:
      LCDOut $fe,$C0,"Hub ",dec Hub_ID, " is Close "
    RETURN
    Next, how different are the HSEROUT strings for each hub? I see only two bytes differ in the open/close commands for Hub 0, what do they look like for Hub 1? What's the "pattern"?

    If only two bytes changes between hub and command then have an array with the 10 bytes, change what's needed and GOSUB a subroutine that spits out the array. Like:
    Code:
    Cmd VAR BYTE[10]
    Cmd[0] = 0
    Cmd[1] = 2
    Cmd[2] = 0
    Cmd[3] = 16
    Cmd[4] = 67
    Cmd[5] = 45
    Cmd[6] = 255
    Cmd[7] = 15
    Cmd[8] = 222
    Cmd[9] = 3
    
    GOSUB SendCmd
    
    
    SendCmd:
      HSEROUT [STR Cmd\10]
    RETURN
    For the next hub/command, you simply change the bytes that needs changing (or re-write them all if you're not THAT tight on space) and then GOSUB SendCmd.

    /Henrik.

Similar Threads

  1. Au full quiet out here...
    By Dave in forum Off Topic
    Replies: 1
    Last Post: - 9th August 2018, 04:36
  2. Replies: 11
    Last Post: - 17th August 2010, 17:45
  3. 18F4550 full speed
    By gigel in forum USB
    Replies: 2
    Last Post: - 14th July 2008, 22:26
  4. Replies: 4
    Last Post: - 2nd March 2007, 07:12

Members who have read this thread : 3

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