Parallax propeller 2 - Part 2: Development environment and code products Code forgot login password?Thank you for registration for your assessment!Thanks for your review!

Parallax propeller 2 - Part 2: Development environment and code products Code forgot login password?Thank you for registration for your assessment!Thanks for your review!

After the basic discussion of the Propeller 2 microcontroller from Parallax and its functions, I would now like to go into the development environment and programming.Below you will learn how to control an LED, for example.

Access to onboard LEDs

It starts with software environment and the control of one of the LEDs on the board.The software development is carried out on Windows 10 with the tools offered by the Parallax.In the end, a basic software setup is available with which you can compile code and push the result on the propeller 2.

Parallax is currently making its propeller tool available in version 2.3 Alpha.It contains the propeller 2 support for the programming language spin2.If you prefer assemblers, you can also use PNUT as a development environment or inline assembler.If you like to program like me in C/C ++: Suitable compilers and development environments are unfortunately not yet ready.In this regard, you can watch a video [1] via C/C ++ on Propeller◦2.

Basic development environment

The URL for download the Propeller Tool 2.3 Alpha can be found under [2].First, however, the download of the Propeller Tool 1.3.2, and in the second step, the executable file propeller tool 2.3 Alpha is copied into the program directory.You can then start the editor and start programming.Figure 1 shows the user interface.

Assembler or Spin2?

Should you use spin2 or assembler for the first program?For the sake of simplicity, spin2 continues.SPIN2 is interpreted like most basic dialects - but differently.Commands and language references to Spin2 can be found in the propeller tool under the Help menu (see Figure 2).

There is still a temporary manual for starting that is unfortunately not yet finished.This leads to the current Spin2 documentary for propeller 2.

Due to the interpretation, a SPIN2 command requires about six instruction cycles = 12 cycle cycles.This does not exactly result in the most fastest program version, but SPIN2 offers an easier start as an assembler.Since Spin2 is a high-level language, there are many assembler instructions to be carried out behind most Spin2 commands-but are easier to use than pure assembler code.Figure 3 shows how a new Spin2 project is created.

Propeller 2 i/o pins

Before you start programming, you should first familiarize yourself with the I/O pins.In the following you will be used as ordinary I/O pins, and only later there is a detailed overview of all your skills.To create a low or high level on a PIN, you have to configure it as an outcome beforehand.The LEDs designated with P56 to P63 are located on the evaluation board (see Figure 4).

Parallax Propeller 2 - Teil 2: Entwicklungsumgebung und Code Produkte Code einbetten Login Passwort vergessen? Zur Registrierung Vielen Dank für Ihre Bewertung! Vielen Dank für Ihre Bewertung!

These LEDs are connected to the pins 56 to 63 of the Propeller 2.For the first example, the first LED P56 is to be controlled.In the circuit diagram, we are clear that it is not directly connected to the chip, but with the Oktal buffer 74HCT244.With their anode, the LEDs are permanently at VCC.In order to shine, the buffer must pull their cathode to mass potential (see Figure 5).

Inverted LED

For the code, this means that the LED stays dark at a high level on the MCU pin and only lights it up at a low level.Thanks to this inverted logic, the code must put the LED pins on "high" so that the LEDs remain dark.If you don't do anything, these pins act by default as an entrance, and the corresponding buffers behave as if their entrances are controlled with a high level.As a result, the LEDs initially remain dark.In order to have the LED P56 lighted up using Spin2 code, the following must happen:

Initialization of the MCU and at least one core (COG).

Set PIN 56 as an outcome

PIN 56 Set Low

do nothing

The initialization actually necessary in the first point has already been done and can be ignored for this example.The Spin2 program only needs a few lines of code.This begins with the function call Pub Main (), followed by the Pinwrite () method (see Fig. 6).

The Pinwrite () method is included in Spin2 and allows one or more pins to be proven with a certain value.Since the LED P56 is controlled by PIN 56, this pin is handed over to the level '0' to bring the pin to low and thus switch on the LED.The last line repeat leads into an endless loop because the code is carried out again and again under Repeat.In this case, however, there is no further code, which is why the corresponding “cog” always does nothing.Without this repeat, the end of the code would be reached and the I/O pins would no longer be controlled.

Translated code to propeller 2

Wenn der Code fertig ist, können Sie ihn auf das Propeller 2 Evaluation Board hochladen und ausführen lassen. Dazu wird das Board einfach per USB mit dem PC verbunden und das Menü Run->Compile Current->Load RAM ausgewählt, damit der Code direkt in das RAM der MCU geladen und ausgeführt wird. Wenn nun die LED P56 leuchtet, war die MCU-Version von „Hello world“ erfolgreich. Falls Sie sich nun fragen, wie man die LED zum Blinken bringen kann: In Spin2 gibt es den WAITMS-Befehl. Beispielsweise verzögert WAITMS(500) die Ausführung des nächsten Befehls um 500 ms. Da der Code nach repeat immer wieder ausgeführt wird, ist das die Stelle, wo man die LED zum Blinken bringen kann. Die nächste Übung besteht also darin, den Code entsprechend zu verändern. Mit den bisherigen Informationen sollte es Ihnen möglich sein, den Code so zu modifizieren, dass die LED P56 nicht nur leuchtet, sondern blinkt. Hierfür gibt es später noch eine exemplarische Lösung.

If you can successfully head for an I/O-PIN, you should find out how serial data is sent in the next step.MCU programmers are used to this type of debugging, especially if you have written software for AVR controllers, for example.Since this works well with the smart pin functions, the next part of this series will rotate exactly.

(200479-B)

Do you want to read other elector articles?Now become an elktor member and don't miss anything!