-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, One of the properties of Flash memory is that changing a 1 bit to a 0 bit is very different to changing a 0 bit to a 1 bit. That's where this issue comes from. Flash memory can easily change a single bit from 1 to 0, and that's exactly what the "write" operation does: for each 0 bit in the data you're writing, it zeros out that bit in Flash; for each 1 bit in the data, it does nothing. This gives you exactly the outcome you want, IF the memory starts out containing all 1s. If it doesn't start out with all 1s, you might see a 0 in Flash where your data to write had a 1. PICs require you to do a "write" with more than one byte at a time for power and speed reasons: it takes time and power to write to Flash, so it's better to do more bytes in parallel (in your case, 8 bytes). It's a lot harder to change 0s to 1s. You can't do this on a bit-by-bit basis (that's why a "write" operation does nothing if it sees a 1). You can only take a large pile of bits (a "row", in your case 64 bytes) and change them all to 1s together. This is called an "erase". Using these two operations together, you can get any data you want into Flash: you first have to erase the area (to make it all 1s) then you have to write the area (to make some of the bits 0). So if you want to fill a large region of Flash with data, you would first erase the region 64 bytes at a time, then you would write the region 8 bytes at a time. Chris Mike snyder wrote: | I am trying to understand how bootloaders work and was reading the | PIC18 datasheets for how one would write to program memory. | | 1. I understand that you can only erase memory in rows of 64 bytes is | that correct? | 2. The bootloader described in AN851 says | | "For the PIC18F devices, commands 1 through 3 support operations to | FLASH program memory. Read operations occur at the byte level. Write | operations are performed on multiples of 8 bytes (one block). Erase | operations are performed on 64 bytes (one row)." | | Does this mean that program memory can be written in 8 byte chunks? | | Any pointers appreciated. | | Thanks | Mike -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: GnuPT 2.7.2 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkhSzYAACgkQiD2svb/jCb4oTACdFIpJdBCCcR00bB21Hm/WbMwE OUsAn3pMXxLvCZqYZEzHPtG6T2TAhjOI =afGL -----END PGP SIGNATURE----- -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist