Shop OBEX P1 Docs P2 Docs Learn Events
simple newbie question: — Parallax Forums

simple newbie question:

stevewrightstevewright Posts: 4
edited 2006-09-19 12:50 in BASIC Stamp
I want to use a page memory chip in a BS2 project. The page memory chit is a 24LC16B, data is read and written serialy using two I/O lines from the BS2. There is a lot of toggeling and pulsing on these two lines, so I want to put groups of LOW 9, HIGH 8, and the like on one program line. I would like to do: LOW8, HIGH 9, HIGH 8, PULSOUT 9, LOW 8, PULSOUT 9, PULSOUT 9. And do them all on one line. Can a multiple commands be put on one program line? I really do not want to use 70 lines of code to write one byte of data.

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-09-19 02:53
    Hello,

    ·· You might want to check out the attached code for reading and writing to the 24LC16 without all those LOW and HIGH commands...I hope this helps.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-09-19 02:53
    Well, they DO make SPI interfaced devices, which would use the SHIFTIN/SHIFTOUT commands at about 56 KBits/sec.

    The 24LC16 is an I2C part. There's already existing code that helps a BS2 interface with I2C devices.· And yes, that does take 70 LOC, and about 200 bytes of the BS2 eeprom.· Still, what's your alternative?

    Oh, and "LOC" is not that important a metric in the BS2.· What IS important is the amount of EEPROM in the BS2 that gets used.· You could put everything on ONE loooong line, and use 200 bytes.· Changing the number of lines used doesn't affect the amount of memory used.

    Post Edited (allanlane5) : 9/19/2006 2:57:39 AM GMT
  • stevewrightstevewright Posts: 4
    edited 2006-09-19 10:53
    Thank you for the code and the information. I will put the code to use today and will also look into SPI devices. Next I am going to interface to AtoD and DtoA devices, then larger external ROM.
    Again, thank you.
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-09-19 12:50
    What DOES affect the memory used is the number of PBasic 'Tokens' (and DATA statements). Each PBasic 'keyword' gets compiled into a 'token', and takes up one byte of the PBasic EEPROM program space.

    Comments don't count. 'CON' statements don't count. An IF or SEROUT does count.
Sign In or Register to comment.