Skip to content
Parallax Learn

Parallax Learn

  • Welcome
  • Tutorials
        • Tutorial Series head tag

          Tutorial Series
        • Tutorial Series

          The special, classroom-ready series pages are organized collections of tutorials for our most popular hardware and/or languages. The tutorials for each topic are conveniently accessible from a single page, shown in the order it is recommended that they be completed.
        • Robotics Series Head tag

          Robotics Series
        • Robotics Series

          • Artificial Intelligence
          • Cybersecurity: Radio Data tutorialCybersecurity
          • cyber:bot + Python
          • cyber:bot + MakeCode
          • Boe-Bot Tutorial SeriesBoe-Bot
          • Arduino Shield-Bot
          • ActivityBot with C TutorialsActivityBot + C
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot + BlocklyProp
          • Scribbler 3 Tutorial SeriesScribbler 3
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education
          • Propeller C-Language BasicsPropeller C Basics
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit + C
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit + BlocklyProp
          • Badge WX Tutorial SeriesBadge WX
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics
          • View All Tutorial Series »
        • Browse Tutorials
        • Browse Tutorials

          Individual tutorials sorted by robot or kit, and language.
        • By Robot or Kit
          • ActivityBot
          • SumoBot WX
          • Boe-Bot
          • Shield-Bot
          • cyber:bot
          • Badge WX
          • ELEV-8
          • ARLO
        • By Language
        • By Language

          • Propeller C
          • Arduino
          • BlocklyProp
          • PBASIC
          • Python
          • MakeCode
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses
  • BlocklyProp Functions and Multicore

BlocklyProp Functions and Multicore

A Bit About Multicore

In the last tutorial, a function you created only ran when it was called by the run function block.  There are, however, situations where you need a function to run continuously on its own in the background while the rest of the program keeps going, Such a background function might keep watch on a button press or a sensor reading. The Propeller chip on the Activity Board (original or WX version) can do more than one thing at a time easily, because it is a multicore microcontroller. You will try that in the next lesson. But first, let’s visualize this multicore thing before we work with it directly.

 

First, a bit about microcontrollers and multicore

A microcontroller is an integrated circuit that includes a tiny processor “brain” to do the “thinking” and some memory for “taking notes” so it can keep track of what it is doing. Microcontrollers also have input/output pins, I/O pins for short, that can exchange electrical signals with other devices such as lights, switches, beepers, motors, and sensors.

A single-core microcontroller has just one processor inside. It is multitasking when it executes several tasks that must share its single processor. The processor must interrupt each task and switch briefly to another, to keep all of the processes going.

Imagine a chef in a kitchen alone, making bread, roast beef, and sauce. The chef must knead the bread dough for 15 minutes, interrupt that task every minute to stir the sauce, and remove the roast from the oven as soon as a thermometer reaches 120 °F. At any moment, the chef (processor) is executing only one task, while keeping all three processes (kneading, stirring, roasting) going at once.

Now imagine being that chef.  The more tasks you must do at once, the more difficult it gets to keep track of them all, and keeping the timing right becomes more of a challenge.

A multicore microcontroller has two or more processors inside. It is multiprocessing when it executes several tasks at once, with each task using its own processor. This is also referred to as true multitasking.

Imagine a chef in a kitchen with three assistants, making bread, roast beef, and sauce. The chef puts one assistant at the stove to stir the sauce every minute. Another assistant is sent to keep watch on the thermometer and remove the roast when it reaches 120 °F. Now the chef is free to knead bread dough for 15 minutes. The three cooks (processors) are keeping all three processes (kneading, stirring, roasting) executing at the same time, without any task-switching interruptions, and without missing the moment when the thermometer reaches 120 °F. There is even an extra assistant ready to help if something more is needed.

Multiple cores makes it easier to do many tasks at once, especially if precise timing is needed.

The Propeller microcontroller has 8 cores (sometimes called cogs) and so can do multiprocessing, also called true multitasking. The cores are all the same. It has 32 I/O pins, which are also all the same. Each core can work with every I/O pin. This means that all of the Propeller cores and I/O pins are equally good at any tasks they must perform. Each core has a bit of its own memory. Each core also takes turn accessing its Hub, where a larger Main Memory (a big “notepad”) allows them to share information.

Got it? Now, let’s try using the new processor block to run a function in its own Propeller core.


Printer-friendly version
Functions in BlocklyProp
Prev
New Processor Blocks
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: [email protected] | Copyright©Parallax Inc. 2024

© 2025 Parallax Learn • Built with GeneratePress