liam.zbasic wrote:3. ZX-40A... code resides in program memory (64K available, ~100,000 write cycles permitted)
One source of confusion is that the memory spaces and write cycle limitations are somewhat different depending on which ZX device is being considered. On VM devices like the ZX-24a, ZX-40a, etc. your code is stored in an EEPROM that is external to the AVR chip. On those devices, then Program Memory is the external EEPROM chip and the write cycle limit is a million cycles. On larger VM devices (e.g. ZX-1281, ZX-1280) and on all native mode devices, your code is stored in Flash memory that is internal to the AVR chip. Flash memory has a lower write cycle limit, on the order of 10,000 cycles.
liam.zbasic wrote:4. All variables defined in simple example reside in RAM. As variables & arrays get updated during ZX-40A code execution, do updates count against the chip write cycles?
The first statement is correct. Note that writes to RAM do not count against the write cycle limit of Program Memory. Practically speaking, RAM has no write cycle limit.
liam.zbasic wrote:What still confuses me is that program memory is also RAM, and separately there is User RAM (3584 bytes).
The AVR chip has only one block of RAM, the size of which varies by device. On VM-mode devices, some of the RAM is reserved for system use (stack, data structures, etc.) and the remainder is called User RAM. The User RAM is further divided into three functional areas: statically allocated data items (e.g. variables defined at the module level), the task stack for the Main() task, and the heap. (The heap is primarily used for the actual characters of a string variable, allocated as needed, but it can also be used for other run-time allocated data.)
For any given program, the size of the statically allocated data is known at compile time. Consequently, the Main() task stack and the heap nominally split the remaining User RAM. (Things are a bit more complicated than that but that will suffice for now, at least for VM mode devices.)
On native mode devices, none of the RAM is reserved for "system" use. Rather, depending on the set of System Library routines that you used, the statically allocated portion includes more or fewer of the "system" data structures in addition to the statically allocated variables that you define and use in your program. As in the VM mode case, the remaining RAM is split between the task stack for Main() and the heap. With native mode devices, you have to think about heap and stack usage a bit more when coding your application than you do with VM mode devices due to some technical peculiarities of native mode.
More information on how RAM is partitions can be found in the ZBasic User Manual.
http://www.zbasic.net/doc/ZBasicRef.php?page=95
To complete the discussion of memory areas, we must also mention Persistent memory. Persistent memory is a non-volatile memory implemented using the internal EEPROM of the AVR. The Persistent memory has a write cycle limit of 100,000 cycles.
Lastly, you should also be aware that you can create both read-only and writeable data items in Program Memory. Although ProgramMemory data items are typically used for table data and are consequently read-only, you can define them to be read-write so that you can update them if you wish.