Shop OBEX P1 Docs P2 Docs Learn Events
What is a Microcontroller? — Parallax Forums

What is a Microcontroller?

PHILMONDPHILMOND Posts: 6
edited 2013-04-29 16:16 in BASIC Stamp
Thanks to PJ Allen for the response to my previous query (on GUI)

To re-formulate my question:
Is it right that the Editor on a click of a RUN button:
  1. translates the listing into machine codes
  2. sends the code (and data) to the MC ROM
  3. starts execution.
From this moment on there is no connection between the Editor and MC.
For example I cannot break an infinite loop from the Editor, however I can PAUSE in the CONTROL window (if it shows up).

I would imagine having a STOP button in the editor with an in-built sequence erasing the MC ROM and stopping execution. Seemingly it does not exist.

Any reference on how PC interacts with MC?
I could not find this info in the "What is a Microcontroller?"

Thanks,
Phil

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-28 15:21
    When you click on the RUN menu item (or use the shortcut), the Stamp Editor translates the current source program into interpretive codes, forces the Stamp to reset which executes a download program in the Stamp's ROM. The Stamp Editor communicates with the download program and transfers the new program's interpretive code into the Stamp module's EEPROM. If the interpretive code is received correctly and copied correctly into the EEPROM, it is automatically started. Because the Stamp Editor can force a reset, the Editor can always force the Stamp to accept a new program which partially overlays what was already in the EEPROM. When a program is RUN, all variables are cleared to zero.

    The PAUSE in the CONTROL window just pauses the display. The Stamp program continues to run and any debug output is ignored.

    The microprocessor on the Stamp module (a PIC for the BS2 or an SX for the other models) is preprogrammed with the Stamp interpreter and download manager in ROM. The Stamp program is stored in a separate EEPROM on the Stamp module. The ROM can only be reprogrammed by Parallax.
  • PHILMONDPHILMOND Posts: 6
    edited 2013-04-28 21:51
    Mike Green wrote: »
    When you click on the RUN menu item (or use the shortcut), the Stamp Editor translates the current source program into interpretive codes, forces the Stamp to reset which executes a download program in the Stamp's ROM. The Stamp Editor communicates with the download program and transfers the new program's interpretive code into the Stamp module's EEPROM. If the interpretive code is received correctly and copied correctly into the EEPROM, it is automatically started. Because the Stamp Editor can force a reset, the Editor can always force the Stamp to accept a new program which partially overlays what was already in the EEPROM. When a program is RUN, all variables are cleared to zero.

    The PAUSE in the CONTROL window just pauses the display. The Stamp program continues to run and any debug output is ignored.

    The microprocessor on the Stamp module (a PIC for the BS2 or an SX for the other models) is preprogrammed with the Stamp interpreter and download manager in ROM. The Stamp program is stored in a separate EEPROM on the Stamp module. The ROM can only be reprogrammed by Parallax.

    Thank you, Mike - an excellent explanation.

    Now - what happens on the push of a RESET button on the Stamp?

    Thanks,
    Phil
  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-28 22:10
    Same thing as when the Stamp Editor forces a reset, the download program is started. In this case, the Stamp Editor is not sending the proper data to the Stamp, so the download program times out, leaves the EEPROM untouched, and it transfers control to the Stamp Basic interpreter which starts executing the program in the EEPROM from the beginning (after clearing the variables).

    Essentially, on a reset when initiated by the Stamp Editor, the Editor asks the Stamp module what model and version it is. If there's no response, the Editor assumes there's no Stamp module present. Whenever a reset is caused by something else like pushing the reset button or initially powering up the Stamp, the download program doesn't hear a request for the model and version within a specific period of time and it times out, therefore assuming that there's no Stamp Editor there.
  • PHILMONDPHILMOND Posts: 6
    edited 2013-04-29 03:58
    Mike Green wrote: »
    Same thing as when the Stamp Editor forces a reset, the download program is started. In this case, the Stamp Editor is not sending the proper data to the Stamp, so the download program times out, leaves the EEPROM untouched, and it transfers control to the Stamp Basic interpreter which starts executing the program in the EEPROM from the beginning (after clearing the variables).
    Does it mean that if the program does not time-out (infinite loop), the reset button has no effect?

    Thanks, Phil
  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-29 06:25
    No. A "time out" is just that. There's a time limit involved. When the time expires, the program does something else (in this case transfers control to the Stamp Basic interpreter).

    A reset, whether caused by pressing a button or by the Stamp Editor toggling the DTR line, is a hardware function and overrides anything else other than lack of adequate power (brown-out).
  • PHILMONDPHILMOND Posts: 6
    edited 2013-04-29 14:39
    Mike Green wrote: »
    No. A "time out" is just that. There's a time limit involved.

    Mike, what is the time limit?

    I ran:
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    DO
    HIGH 15
    PAUSE 250
    LOW 15
    PAUSE 400
    LOOP

    Then I disconnected the Board from PC, pressed Reset button <REALLY HARD> for 5 seconds and 10 hours later the LED is still blinking.
  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-29 15:51
    You don't have to press the button "really hard". When the button is pressed, the Stamp should go into reset and the LED won't blink while the button is pressed. When you let go, the download routine starts executing and quickly (fraction of a second) times out, transferring control to the Basic interpreter. Since your "blinky" program is still in the EEPROM, it will start executing and will continue as long as everything has power.

    The timeout is the maximum allowed time from when /RESET becomes high until a specific character is received from the PC. I don't know the exact character or time involved. The ROM loader for the Propeller is similar and has been published, so you could look at how that works.
  • PHILMONDPHILMOND Posts: 6
    edited 2013-04-29 16:16
    Mike, I was kidding about PRESS HARD.

    Thanks a lot for your explanation.
    You are immensely patient.

    ... and the LED is still blinking ...
Sign In or Register to comment.