Shop OBEX P1 Docs P2 Docs Learn Events
Some pbasic questions? — Parallax Forums

Some pbasic questions?

jonduncanjonduncan Posts: 40
edited 2007-03-03 22:06 in BASIC Stamp
Can i have a nested for loop?


if I create a·

bits var bit(2)

can I do this?

if bits = %01 then·· ....

can i I do math with Nib, what happens when over flow, does it wrap around or does carry out to high bit?
·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-03 05:34
    1) Yes, you can have nested for loops

    2) It won't do what you expect. You've declared a bit array with 2 elements. There's really no way to declare a variable consisting of only 2 bits. A 4 bit nibble is the only size between a single bit and a byte

    3) If a variable is declared as a 4-bit nibble, it can only have values 0-15. If you add 1 to 15, you would get 0 (wrap around).
  • jonduncanjonduncan Posts: 40
    edited 2007-03-03 06:24
    Another question about EEPROM does it check the value before it writes the data, because if the data is the same there is no point writing it, so if a bit in EEprom is a one, and I give a command to write a 1 to that bit, does it write it again? what about bytes? because if a number is a 1 and i write a 3 does in write the least signifcant bit again, what if it is the same number if it was a 3 and I write a three, because I might save time if I do some checking before I write, but if already does some checking before it writes then I don't have to, I am just looking to same time and also help my BS2 last longer.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-03 06:30
    No, it doesn't check for you. It's a very good idea to read the location before you intend to write it and skip the write if it's already what you want.
  • jonduncanjonduncan Posts: 40
    edited 2007-03-03 21:28
    in your opinion would it be good todo a byte wise checking or a bit wise testing, the numbers wont change that much when they change, like they might change from 45 to 47. would bit wise checking take more time then just writing the number. maybe the best would be do a byte wise, then nibble wise then bit wise, but if all the bits switch it would take a lot of time, or maybe just start with nibble testing, beacause it only has to test 2 nibbles in a byte, and if the nibbles are different I could test the bits
  • jonduncanjonduncan Posts: 40
    edited 2007-03-03 22:06
    I looks like I found my answer it look like it writes a byte at a time, according to the tech specs
    http://ww1.microchip.com/downloads/en/DeviceDoc/21713F.pdf
    of the EEPROM so all I would need to do is a byte check
Sign In or Register to comment.