Array of string to send with TX int ?


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1

    Default Array of string to send with TX int ?

    I am trying to come up with a method to :
    -at run time
    -load an array with differing strings, pulled from prog. mem, EEmem and variables.
    -and when ready, send with TX interrupts up to an ending char

    HSERout sucks up much processing time when you send 1,2 or 400 chars even at 115200 bps and 20MHZ.

    I'm stuck on how to index and add to the array (to build the array) with a mixture of strings and variables.

    Incomming RCVieves request the differing data to be sent back.

    thanks for ideas.
    don
    amgen

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: Array of string to send with TX int ? narrowed down

    Hello,
    Narrowing down my question, PBP 2.6 has ARRAYWRIYTE with all the modifiers and will create a string all formatted to an array.
    Is there access to the index pointer used by a 'differing legnth' ARRAYWRITE uses so another ARRAYWRITE can add chars directly to the end of the first write ?

    ARRAYWRITE snd_array , [str str1 ,10,13]

    (str1 may vary in legnth, takes chars up to a 0-zero)
    (add to snd_array directly at the end of first ARRAYWRITE)
    ( find the index to where to start ?)

    ARRAYWRITE snd_array(????) , [str str2 , 00]

    thanks,
    don
    amgen

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Array of string to send with TX int ?

    Not sur filling an array will be better than Hserout, it still take some time to fill it. What I would do is to use a variant of Darrel's embedded string in your codespace for the known data, then maybe you could have an array to store your unknown data into a run time.

    Depending how you format your thing, it may also take some time to process it. Usually we use a NULL character to specify a string/set of data end. This assume you need to check each character, test it and then send it... duh.

    BUT you may have a String/Data start AND end address and loop from the start to the end.. still it always test if you're at the end address.

    Not sure of your requirement, but sure enough, I don't see many advantage over a simple HSEROUT line, code size appart.

    Circular buffer...mmm.....

    Explain your exact requirement, post your code here, we will have a look at that.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: Array of string to send with TX int ?

    Hi Steve,

    Quick overview,
    -18f2525 3k ram
    - DT ints for main timing loop 10X/sec
    -after main loop of code for up to .1 sec, wait for int flag to loop,
    then, the time in wait is idle time, (indicates if using up processing available between interrupts to remain in accurate timing.)
    -Recieve ints work in backround

    -HSEROUT takes up about 80% processing for the loop to send 600 some-odd chars. More hserout will make error for the main timing loops...If you want to count on the main loop for timing. See image of serout.


    Code:
     
    HSEROUT["<name=IDLE_TIME,value=",dec L2,".",dec w1,"%>, _
    ","<name=LONG,value=",dec L1,">",10,13] 
    HSEROUT["IN DATA ARRAY "]       ' pin 14 on F2525                
     
    for ax=1 to                                  'SEND ALL IN MEM BY INDEX
    indx                             
    DAT = RCVDATA[AX]
    HSEROUT[DAT]
    next ax 
     
    HSEROUT [", INDEX COUNT=" , DEC INDX ,10,13]
    Name:  18f2525.JPG
Views: 883
Size:  216.1 KB
    So, TX int will work in backround and not interfere with timing.
    I can post code but I program on my old XP computer and this Vista laptop to internet and the vista blocks my network at times, so I have to get code files to post here.

    thanks for your thoughts
    don

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


    Did you find this post helpful? Yes | No

    Default Re: Array of string to send with TX int ?

    Hi,
    It's not really processing power it's just that HSEROUT sits there waiting for the for TXBuffer to free up before it can put the next byte in. 600 bytes is 6000 bits at 8N1 so at 115200 it should take around 1/115200*6000=52ms. The PIC oscillator frequency has little impact on that as the actuall processing involved in the HSEROUT is quite small (though I guess it increases a bit with the all the modifiers).

    ARRAYWRITE should work exactly the same as HSEROUT except it will put all your data in an array in RAM. So if if you have enough RAM (600 bytes?) simply replace HSEROUT with ARRAYWRITE and write your complete string to memory (or do it parts if you don't have the RAM). At the very end you pad a NULL or other character that you can use to identify the end of the string.

    Then, to have the transmit interrupt driven, have a look at this post

    I'm sure the ARRAYWRITE index counter is available in one of the system variables but I have no idea which. You should be able to handle it by multiple arraywrites and "send-sessions". Load array, send, reload array send etc. Have a semaphore that the ISR cleares when it finds the end of the current outgoing string, that way the main routine knows when it can reload the array with the next part of the message.

    But, like I said, it's not going to take less time to send 600bytes either way but you're going to have access to the processor during the time it takes to actually get the byte from the TXReg and out of the PIC which is like 87us or there abouts for 115200.

    /Henrik.

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: Array of string to send with TX int ?

    Thanks Henrik,
    It seems that ArrayWrite can't access program mem directly, this code didn't work, probably same for EEprom . Looks like it only works for ram to ram functioning.

    Code:
    arraywrite  snd_array ,[str str2,0]   (Didn't work)
    
    
    asm                        ;test tables at top of program mem
                     
    str1   org 0xb100             
        db  "<name=IDLE_TIME,value=",0 
     
    str2   org 0xb200   
        db  "<name=LONG,value=",0 
     
    str3   org 0xb300    
        db  "<name=IP Address,value= 192.168.1.3>",0 
      
    endasm
    like you said, I would have to build string-array piece by piece and send when done or send piece by piece out TX.
    I understand that the time it takes to send 600 chars @ 115200 is the same no matter how its sent, but the machine instructions to send by TX should be much less than HSER or SER. The main loop of 10X per second (100 milli sec per loop) should allow for about 300,000 instructions each .1sec loop without overrunning timer interrupt. The use of interrupts keeps all that constant.
    I think....

    don

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: Array of string to send with TX int ?

    Hi Don,
    It's not clear to me exactly what your trying to do. You say that ARRAYWRITE doesn't access porgram space but that's exactly what it does. It takes data stored in program space and moves it to and array in RAM. It can also copy data from RAM to the array using one of many modifiers, like STR.
    Code:
    String_1 VAR BYTE 128
    String_2 VAR BYTE 64
    Value VAR BYTE
     
    Value = 123
     
    ARRAYWRITE, String_2, [" and this is the second part of the string.",0]
    ARRAYWRITE, String_1, ["This is the first part,", STR String_2, " The variable value is: ", DEC Value, 0]
    The STR modifer writes the contents of String_2 in this case to String_1. It stops when it sees the 0 padded to the end of String_2. I don't think it actually writes that 0 in which case we're in trouble....

    However, since I don't fully understand your problem I'm not sure this helps at all. If you have enough RAM to store the full 600+ bytes string you could build the string with a single ARRAYWRITE statement, pad a zero at the end and then enable the TX interrupt to have it sent in the background.

    I'm sorry if I'm completely missing the point here....

    /Henrik.

Members who have read this thread : 0

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