Shop OBEX P1 Docs P2 Docs Learn Events
Prog SX Micro Tutorial Book; Clear data memory tut010 — Parallax Forums

Prog SX Micro Tutorial Book; Clear data memory tut010

megazoicmegazoic Posts: 5
edited 2008-12-11 06:24 in General Discussion
Hi, I'm going through G. Daubach's tutorial 010 for the sx28 "Clearing the Data Memory and Indirect Addressing" and the following code...
Main
   clr fsr
ClearData
   sb   fsr.4
   setb   fsr.3
   clr   ind
   ijnz   fsr, ClearData
   jmp $



is supposed to clear only data memory. Yet when I step through this, I see that the fsr includes addresses for program memory too.
I have two questions.
1) Is it correct to say that the clr ind command is clearing the program memory when the fsr holds addresses for those pages?

2) if so does the sx-key debugger hold the program in some other memory so that the application still executes even after the program memory has been cleared?

Thanks in advance of any thoughts!

Nick

Comments

  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2008-12-10 22:04
    Nick,

    due to its structure, it is impossible that the SX can overwrite program memory. The SX has a so-called Harward structure where program memory and data memory both have separate address and data busses. Program memory is 12 bits wide, and data memory is 8 bits wide. There is one instruction (IREAD) which allows to read data from program memory but there is no instruction allowing to write into program memory. Besides this, program memory is flash memory which can only be written to with a special external hardware mode but not via the internal busses.

    When an instruction has IND as parameter, like with CLR IND, this means that the FSR contains the full memory address, and not only the pages. So, the FSR can address memory from $00 up to $FF. When clearing program memory, it is important not to touch any memory address from $00 up to $07 (SX20/28) or $09 (SX48) as special registers are mapped into this address range. This is why the code contains the sb fsr.4 and setb fsr.3 instructions.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • BeanBean Posts: 8,129
    edited 2008-12-10 22:24
    Nick,
    Yeah this is one thing I confused me alot when I started with microcontrollers.

    There are two seperate address areas. So in other words, there is a PROGRAM memory location 0, and there is also a totally seperate RAM memory location 0.

    It's takes awhile to get your head around this when you are so used to PC programming, where the program resides in RAM. Microcontrollers are different.

    Note that PROGRAM memory can be read by using the IREAD instruction. But the SX itself cannot write to PROGRAM memory.

    Bean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    "The welfare of the people in particular has always been the alibi of tyrants." ~ Camus
    www.iElectronicDesigns.com

    ·
  • megazoicmegazoic Posts: 5
    edited 2008-12-11 06:24
    Thanks for clarifying this G
Sign In or Register to comment.