Shop OBEX P1 Docs P2 Docs Learn Events
I2C ReadPage with specific memory location assignment - SOLVED — Parallax Forums

I2C ReadPage with specific memory location assignment - SOLVED

4Alex4Alex Posts: 119
edited 2009-07-31 11:40 in Propeller 1
Good evening everybody,

I am trying to reduce my code as much as possible. I read 16 bytes from the eeprom and I would like to assign these bytes to a buffer starting at a specific location. I do this a lot using different addresses and final positions. Is it possible to replace the following code with something shorter (and faster)? Ideally I'd like to put everything in the ReadPage command.

i2c.ReadPage(i2cSCL, $A0, $8118, @tmpMX, 16)
repeat i from 0 to 15
  comms_txbuf[noparse][[/noparse]14+i] := tmpMX[noparse][[/noparse] i ] '





Thanks for any help.

Cheers,

Alex

Post Edited (4Alex) : 7/31/2009 11:43:19 AM GMT

Comments

  • BradCBradC Posts: 2,601
    edited 2009-07-31 03:48
    4Alex said...
    Good evening everybody,

    i2c.ReadPage(i2cSCL, $A0, $8118, @tmpMX, 16)
    repeat i from 0 to 15
      comms_txbuf[noparse][[/noparse]14+i] := tmpMX[noparse][[/noparse] i ] '
    
    
    



    Try this on for size.

    i2c.ReadPage(i2cSCL, $A0, $8118, @comms_txbuff[noparse][[/noparse]14], 16)
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <This space for rent>
  • JonnyMacJonnyMac Posts: 9,197
    edited 2009-07-31 03:51
    I don't think you're going to get there in one line. You can use pointer to the tx buffer but unless you use the standard interface to the serial routine the buffer pointers won't be updated and nothing will go out. I'm assuming, based on your code, that you want to grab a string from the EEPROM and send it out serially with as little fuss as possible.

    [noparse][[/noparse]Edit] Of course, if you're just building a buffer that will be transmitted elsewhere, Brad's suggestion should work.
  • 4Alex4Alex Posts: 119
    edited 2009-07-31 11:40
    @BradC: Thank you so much for your reply. Yes, that's exactly what I was looking for. It's really going to save me a *lot* of lines.

    @JonnyMac: Thanks for your reply. Yup, I'm building a transmission buffer over several different input sources, so I do need BradC's function.

    Cheers,

    Alex

    p.s.: the more I use the propellers, the more I'm amazed at the shear power of it compared to PIC mcu. Discovery never stops. Kudo Parallax!
Sign In or Register to comment.