Sending multiple serial strings.


Results 1 to 6 of 6

Threaded View

  1. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Sending multiple serial strings.

    Hi,
    Why does it "waste" RAM? Could it be stored in ROM instead?
    Waste may not have been the best word. What I mean is that the string for each command is static, they don't change, so there's no real need for them to live in RAM - which they'll do if you follow option 1 in my previous post. Again, there's nothing inherently wrong with this and it might be the easiest way if you have the RAM to spare.


    It IS stored in ROM (FLASH actually) when you do it like
    Code:
    HESEROUT [$55, $AA, $01, $FF, $00, $00, $AA, $56]
    Which means that option 2 does, obviously, use less amount of RAM.

    With PBP3 there are ways to create unique usercommands but it's a pretty advanced topic. With the information given so far I'd go for option 2. Create a subroutine for each of the 24 commands and call them in sequence using GOSUB.

    /Henrik.

    EDIT: And if you DO go for option 2 and want to save some codespace you could probably do that by creating a "send header" and a "send footer" sub so you don't need to store the same 4 bytes for each command 24 times.
    Code:
    mcuStop:
      GOSUB SendHeader : HESEROUT [$01, $FF, $00, $00] : GOSUB SendFooter
      RETURN
    
    SendHeader:
       HSEROUT [$55, $AA]
       RETURN
    
    SendFooter:
       HSEROUT [$AA, $56]
       RETURN
    EDIT2: And now, if you use an 18F part and have LONGs enabled you COULD possibly do something like:[code]
    Code:
    Header CON $55AA
    Footer CON $AA56
    MotorStop CON $01FF0000
    
    mcuStop:
      GOSUB SendHeader : HESEROUT [MotorStop] : GOSUB SendFooter
      RETURN
    
    SendHeader:
       HSEROUT [Header]
       RETURN
    
    SendFooter:
       HSEROUT [Footer]
       RETURN
    Watch out for Little vs big endian, I'm not sure, off the top of my head how it's being sent here so you may need to reverse it.
    Last edited by HenrikOlsson; - 27th September 2014 at 11:03.

Similar Threads

  1. Problem on sending data on serial port
    By bwaxing in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 3rd May 2011, 21:05
  2. Store and retrieve strings to an ATmel SPI Serial EEprom
    By BryanSw in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 13th August 2010, 02:17
  3. Need help sending a hex serial output
    By cruzn27 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 5th December 2009, 13:24
  4. Parse Strings from (Assembly) Serial Interrupt
    By orlandoG in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th April 2007, 16:17
  5. VB sending serial data to PIC
    By Tissy in forum Serial
    Replies: 7
    Last Post: - 8th March 2006, 18:31

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts