Shop OBEX P1 Docs P2 Docs Learn Events
After the END — Parallax Forums

After the END

John KauffmanJohn Kauffman Posts: 653
edited 2006-11-09 18:22 in General Discussion
I’m trying to understand some theoretical stuff about SX. As I’ve said before, this was all probably covered in the EE courses I never took. My thanks to you guys for the remedial work.
·
I wrote a program where the Main: finished with END. I pictured the program would stop and the SX shut down. There would be no more flow of electrons through the chip.
·
I wrote a simple interrupt routine (triggered by a pin B). I figured that I had to have some kind of loop (even just GOTO MAIN) to keep the chip humming to receive the interrupt.
·
But then (by mistake) I observe that even without a loop, the SX seems alive enough to respond to an interrupt. In other words, after an END the chip has not shut down.
·
This leads me to believe that the chip has functionality beyond what happens in code between Start: and END. I now have a mental model that there is some kind of meta-code that is running in the background.
·
Bean helped me by noting that END just starts a loop of END; Jmp END. He explained that this meta-function was managed by micro-code.
·
This all makes sense, given that a microcontroller would normally be running all the time the project is powered up.
·
Questions:
  1. Are there any errors in my thinking described above?
  2. Does the RTCC also continue after the END?
  3. Does END by itself cut current consumption for the battery to zero? (SLEEP reduces it further but also not to zero?) Is there any way to reduce current to zero other then unplugging the chip?
  4. Does the BASIC STAMP also keep running microcode as long as it is powered?
·
Thanks for taking the time to clarify this stuff for me.

Comments

  • BeanBean Posts: 8,129
    edited 2006-11-09 15:00
    John,
    You're giving END more credit than it deserves. END creates a loop, and nothing more. Nothing..

    2) Yes, again END is nothing but a loop.

    3) END does not affect current at all. Removing power is the only way to get the current to zero.

    4) In sleep mode the clock (resonator) is stopped. Only the watchdog circuitry is running (it has it's own 14KHz clock). So when the stamp is powered and in sleep mode, microcode(instructions) is/are not being executed.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com

    "People who are willing to trade their freedom for·security deserve neither and will lose both." Benjamin Franklin
    ·
  • John KauffmanJohn Kauffman Posts: 653
    edited 2006-11-09 15:17
    Thanks Bean, that clarifies the picture.
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2006-11-09 18:22
    Actually, END is a directive for the assembler, and not an instruction for the SX. So, an END directive in an assembly source file "tells" SASM that the source code ends here, i.e. SASM will ignore any text following this END directive. This sometimes is handy as you may add any text information to a source code file following the END.

    How the SX behaves after the last valid instruction before the END directive (or at the end of a source code file when there is no END directive) depends on what this directive looks like. Often, this is a JMP to some program location in order to execute a continuous loop of instructions. It could also be a SLEEP instruction which sends the SX to sleep mode, or it might be a JMP $ instruction which sends the SX into an endless loop, doing nothing else. The last example is not really meaningful, and might only be used for testing purposes. In a "real" application, you usually keep the program running in a loop to do meaningful operations, or - maybe - into sleep state in order to re-execute the program after a wake-up event.

    In case, you don't place such kind of an instruction before the END directive, the remaining part of the program memory will be set to $FFF, and program execution continues through this part (doing nothing but incrementing the program counter) until the program counter addresses the highest location in program memory where a JMP to the reset location is found. So, the program will then continue at this location.

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

    G
Sign In or Register to comment.