<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>ColdFire/68K Microcontrollers and ProcessorsのトピックIntroducing StickOS BASIC for MCF52221 ColdFire MCU (beta, long)...</title>
    <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Introducing-StickOS-BASIC-for-MCF52221-ColdFire-MCU-beta-long/m-p/179155#M7210</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Recently, I had a few embedded system projects I wanted to do with the MCF52221 ColdFire MCU, including controlling my toaster oven to do SMT reflow soldering...&amp;nbsp; In addition to that, one of my dreams for a long time has been to make these kinds of projects more accessible to high-school and college age hobbyists, like I believe they used to be in the past.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, one thing led to another and we ended up writing an entire resident “StickOS BASIC” embedded system programming environment &lt;I&gt;that runs entirely within the MCF52221 ColdFire MCU,&lt;/I&gt; including an easy-to-use editor, compiler, flasher, and debugger, where external pins are mapped to special “pin variables” for manipulation or examination, and internal peripherals are managed by BASIC control statements and BASIC interrupt handlers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And we finally have a website up!!!&amp;nbsp; (But now we need to redesign the graphics so the text is not clipped on windows narrower than 1024 pixels...)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone wants to try it out, StickOS BASIC runs as-is on an M52221DEMO board with the CLK0 jumper installed (or basically any board using an MCF52221 ColdFire MCU and either an 8MHz crystal or the internal relaxation oscillator enabled).&amp;nbsp; Download information, including the S19 ColdFire binary image and full documentation, is below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can log into the MCF52221 from any USB host computer that supports an FTDI Serial Port (including Windows and Linux) and then control it by a terminal emulator program, &lt;I&gt;with no additional software or hardware required on the host computer&lt;/I&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By its very nature, StickOS supports in-circuit emulation when it is running in the MCF52221 -- all you need is three (USB) wires connecting the MCF52221 to a USB host computer, and you have full control over the target embedded system!&amp;nbsp; The USB host computer may then be disconnected for standalone operation.&amp;nbsp; (Or it may be left attached if you just want to use the MCF52221 as a slave data acquisition device!)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When you initially log in you’ll see a command prompt in the terminal emulator window like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;Welcome to StickOS for Freescale MCF52221 v1.01!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;Copyright (c) CPUStick.com, 2008; all rights reserved.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; _&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone remembers the old HP-2000 TimeShare BASIC systems from the 1970’s, that’s what inspired me to do this...&amp;nbsp; In StickOS BASIC, however, the CPU and filesystem, not to mention the I/O system, are all on a single chip! You talk directly from the terminal emulator to the MCF52221!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style=": ; font-size: 4;"&gt;Hello World!&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So what does the “Hello world!” program look like in StickOS BASIC?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Well, if the baseline goal for an embedded system is to configure an I/O pin and get an LED to blink, such as LED1 on pin DTIN0 of the M52221DEMO board, then the “Hello world!” program looks like this (entered text is in &lt;STRONG&gt;bold&lt;/STRONG&gt;):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;10 dim led1 as pin dtin0 for digital output&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;20 while 1 do&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;30&amp;nbsp; &amp;nbsp;let led1 = !led1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;40&amp;nbsp; &amp;nbsp;sleep 500&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;50 endwhile&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;lt;Ctrl-C&amp;gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;STOP at line 40!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; _&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Line 10 declares a “pin variable” named “led1”, then configures the general purpose I/O pin “dtin0” for digital output, and finally binds the pin variable to the corresponding pin (in traditional BASIC, the “dim” statement is used to “dimension” the shape of a variable prior to use).&amp;nbsp; From then on, any modification of the pin variable is immediately reflected at the I/O pin.&amp;nbsp; Line 20 starts an infinite loop.&amp;nbsp; Line 30 inverts the state of the dtin0 digital output pin.&amp;nbsp; Line 40 delays the program for 500 ms.&amp;nbsp; And finally line 50 ends the infinite loop.&amp;nbsp; Press &amp;lt;Ctrl-C&amp;gt; to stop the program.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Of course, if you really *just* wanted to print “Hello world!” to the terminal (assuming it was still connected &lt;SPAN aria-label="Happy" class="emoticon_happy emoticon-inline" style="height:16px;width:16px;"&gt;&lt;/SPAN&gt;, you could just do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;10 print "Hello world!"&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;Hello world!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;_&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style=": ; font-size: 4;"&gt;Hello Accelerometer!!&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want to read analog input pins in StickOS BASIC, it’s just as easy...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To control and monitor the accelerometer on the M52221DEMO board, you could use the following program:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;10 dim x as pin an4 for analog input&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;20 dim y as pin an5 for analog input&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;30 dim z as pin an6 for analog input&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;40 dim gsel1 as pin utxd1 for digital output&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;50 dim gsel2 as pin urxd1 for digital output&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;60 dim wake as pin ucts1* for digital output&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;70 let gsel1 = 0&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;80 let gsel2 = 0&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;90 let wake = 1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;100 while 1 do&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;110&amp;nbsp; &amp;nbsp;print "x =", x, "; y =", y, "; z =", z&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;120&amp;nbsp; &amp;nbsp;sleep 1000&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;130 endwhile&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;x = 1583 ; y = 1656 ; z = 2456&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;x = 1576 ; y = 1662 ; z = 2458&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;x = 1593 ; y = 1655 ; z = 2465&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;x = 1572 ; y = 1656 ; z = 2455&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;lt;Ctrl-C&amp;gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;STOP at line 120!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;_&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lines 10-30 declare “pin variables” named “x”, “y”, and “z”, then configure I/O pins “an4”, “an5”, and “an6” for analog input, and finally bind the pin variables to the corresponding pins.&amp;nbsp; From then on, examination of the pin variables results in the current ADC values being read.&amp;nbsp; Lines 40-90 control the gsel1, gsel2, and wake (actually sleep*) pins of the accelerometer (see the M52221DEMO board schematic).&amp;nbsp; Lines 100-130 poll the accelerometer every second and print the results to the terminal, in millivolts (mV).&amp;nbsp; Press &amp;lt;Ctrl-C&amp;gt; to stop the program.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style=": ; font-size: 4;"&gt;Hello Toaster Oven!!!&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What if you want to use interrupts?&amp;nbsp; StickOS BASIC supports them also!&amp;nbsp; You can configure timers to interrupt periodically and UARTs to interrupt on character transmit or receive.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following program illustrates the use of a timer interrupt (at lines 50-60 and 130-190), and controls my toaster oven with a convenient SMT reflow temperature profile, when hooked to a K-type thermocouple thru a 100:1 op-amp!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;10 dim target, secs&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;20 dim thermocouple as pin an0 for analog input&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;30 dim relay as pin an1 for digital output&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;40 data 512, 90, 746, 105, 894, 20, -1, -1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;50 configure timer 0 for 1000 ms&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;60 on timer 0 gosub adjust&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;70 while target!=-1 do&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;80&amp;nbsp;&amp;nbsp; sleep secs*1000&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;90&amp;nbsp;&amp;nbsp; read target, secs&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;100 endwhile&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;110 let relay = 0&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;120 end&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;130 sub adjust&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;140&amp;nbsp;&amp;nbsp; if thermocouple&amp;gt;=target then&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;150&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; let relay = 0&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;160&amp;nbsp;&amp;nbsp; else&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;170&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; let relay = 1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;180&amp;nbsp;&amp;nbsp; endif&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;190 endsub&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;save&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;autorun on&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;autoreset on&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;reset&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that if terse code were our goal, lines 60 and 130-190 could have all been replaced with the single statement:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;60 on timer 0 let relay = thermocouple&amp;lt;target&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;“Save” saves the program to non-volatile flash memory, “autorun on” sets the program to run automatically when the CPUStick is powered up, and “autoreset on” sets the CPUStick to automatically reset itself when it is awakened from a sleep (as opposed to continuing running the saved BASIC program from where it left off).&amp;nbsp; Finally, “reset” resets the CPUStick as if it was just powered up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style=": ; font-size: 4;"&gt;Hello Dolly?!?&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using frequency output pins bound to the DMA timers whose value can be set in hertz (Hz), you can play scales or music or whatever else you might dream up, such as:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;10 dim oct&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;20 dim freq as pin dtin0 for frequency output&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;30 let freq = 440&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;40 for oct = 1 to 8&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;50&amp;nbsp;&amp;nbsp; sleep 500&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;60&amp;nbsp;&amp;nbsp; let freq = freq*105946/100000&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;70&amp;nbsp;&amp;nbsp; if oct!=3&amp;amp;&amp;amp;oct!=7 then&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;80&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; let freq = freq*105946/100000&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;90&amp;nbsp;&amp;nbsp; endif&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;100 next&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;110 let freq = 0&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which plays a single octave of the musical scale starting at A-440 (Hz).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style=": ; font-size: 4;"&gt;Other StickOS features...&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* on-line help&lt;/P&gt;&lt;P&gt;* ansi terminal line editing&lt;/P&gt;&lt;P&gt;* transparent line-by-line compilation and de-compilation&lt;/P&gt;&lt;P&gt;* full-featured debugger with breakpoints, assertions, and even edit-and-continue&lt;/P&gt;&lt;P&gt;* load and save up to three BASIC programs in flash&lt;/P&gt;&lt;P&gt;* prolong flash lifetime by storing incremental updates in RAM&lt;/P&gt;&lt;P&gt;* StickOS firmware self-upgrade over USB&lt;/P&gt;&lt;P&gt;* MCU-to-MCU flash cloning over QSPI/EzPort&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style=": ; font-size: 4;"&gt;Who is StickOS for?&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Our main target audience for StickOS is folks doing low-volume hobbyist and educational work.&amp;nbsp; Or more specifically, our main target audience is folks for whom “ease of development” (and even ease of re-development!) is significantly more important than “production cost”.&amp;nbsp; Obviously, for hobbyist and educational use, there is no production!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style=": ; font-size: 4;"&gt;Who is StickOS *not* for?&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;StickOS simply doesn’t make sense for high-complexity, high-performance, high-volume, or cost-sensitive applications.&amp;nbsp; By pushing the development environment to the MCU, you end up using a $6 MCU where you could have gotten by with a $1 MCU, from a performance and resource usage perspective.&amp;nbsp; Likewise for high-volume applications, development costs (and “ease of development”) are nearly moot, since they are amortized over large number of production units.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style=": ; font-size: 4;"&gt;Where is more information on StickOS?&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See &lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.cpustick.com%2F" rel="nofollow" target="_blank"&gt;http://www.cpustick.com&lt;/A&gt; .&amp;nbsp; You can download the S19 ColdFire binary image to flash to your M52221DEMO board, as well as a full set of documentation.&amp;nbsp; There are also C source code examples for the “general purpose” parts of StickOS I thought folks would find useful, including the FTDI/USB transport device driver, S19 file parsing and self-upgrading, flash programming, QSPI/EzPort flash cloning, etc.&amp;nbsp; These source files are available with no restrictions; however, we ask you don’t republish them so we c an fix bugs in the originals.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The “CPUStick” part of the website is the other half of the equation for making these projects more accessible to high-school and college age hobbyists -- it is a small (0.9” by 1.8”) PCB with the MCF52221 running StickOS, with 0.1” header pins suitable for use in either a solderless breadboard or wirewrap environment.&amp;nbsp; You can download Gerber files if you want to make your own PCB.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For now, we can produce a limited number of CPUSticks for folks who want to help with beta test.&amp;nbsp; We are especially seeking educators!&amp;nbsp; Also, if you have other platforms you'd like us to port StickOS to, let us know that, too, as the code is easily portable!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-- Rich&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS The next project we’re just starting is to add a zigbee wireless daughter card (also 0.9” by 1.8”) based on the MC13201 to the CPUStick so you can remotely log in from one CPUStick to another, eliminating the need for the USB connection for all but the first CPUStick!&amp;nbsp; And we’ll add QSPI support to StickOS at the same time, since that’s the MC13201 interface.&amp;nbsp; I’m also considering a port to the (LQFP44) 51JM128, to save $2 and some board real estate.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 09 Aug 2008 05:29:08 GMT</pubDate>
    <dc:creator>RichTestardi</dc:creator>
    <dc:date>2008-08-09T05:29:08Z</dc:date>
    <item>
      <title>Introducing StickOS BASIC for MCF52221 ColdFire MCU (beta, long)...</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Introducing-StickOS-BASIC-for-MCF52221-ColdFire-MCU-beta-long/m-p/179155#M7210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Recently, I had a few embedded system projects I wanted to do with the MCF52221 ColdFire MCU, including controlling my toaster oven to do SMT reflow soldering...&amp;nbsp; In addition to that, one of my dreams for a long time has been to make these kinds of projects more accessible to high-school and college age hobbyists, like I believe they used to be in the past.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, one thing led to another and we ended up writing an entire resident “StickOS BASIC” embedded system programming environment &lt;I&gt;that runs entirely within the MCF52221 ColdFire MCU,&lt;/I&gt; including an easy-to-use editor, compiler, flasher, and debugger, where external pins are mapped to special “pin variables” for manipulation or examination, and internal peripherals are managed by BASIC control statements and BASIC interrupt handlers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And we finally have a website up!!!&amp;nbsp; (But now we need to redesign the graphics so the text is not clipped on windows narrower than 1024 pixels...)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone wants to try it out, StickOS BASIC runs as-is on an M52221DEMO board with the CLK0 jumper installed (or basically any board using an MCF52221 ColdFire MCU and either an 8MHz crystal or the internal relaxation oscillator enabled).&amp;nbsp; Download information, including the S19 ColdFire binary image and full documentation, is below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can log into the MCF52221 from any USB host computer that supports an FTDI Serial Port (including Windows and Linux) and then control it by a terminal emulator program, &lt;I&gt;with no additional software or hardware required on the host computer&lt;/I&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By its very nature, StickOS supports in-circuit emulation when it is running in the MCF52221 -- all you need is three (USB) wires connecting the MCF52221 to a USB host computer, and you have full control over the target embedded system!&amp;nbsp; The USB host computer may then be disconnected for standalone operation.&amp;nbsp; (Or it may be left attached if you just want to use the MCF52221 as a slave data acquisition device!)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When you initially log in you’ll see a command prompt in the terminal emulator window like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;Welcome to StickOS for Freescale MCF52221 v1.01!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;Copyright (c) CPUStick.com, 2008; all rights reserved.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; _&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone remembers the old HP-2000 TimeShare BASIC systems from the 1970’s, that’s what inspired me to do this...&amp;nbsp; In StickOS BASIC, however, the CPU and filesystem, not to mention the I/O system, are all on a single chip! You talk directly from the terminal emulator to the MCF52221!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style=": ; font-size: 4;"&gt;Hello World!&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So what does the “Hello world!” program look like in StickOS BASIC?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Well, if the baseline goal for an embedded system is to configure an I/O pin and get an LED to blink, such as LED1 on pin DTIN0 of the M52221DEMO board, then the “Hello world!” program looks like this (entered text is in &lt;STRONG&gt;bold&lt;/STRONG&gt;):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;10 dim led1 as pin dtin0 for digital output&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;20 while 1 do&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;30&amp;nbsp; &amp;nbsp;let led1 = !led1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;40&amp;nbsp; &amp;nbsp;sleep 500&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;50 endwhile&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;lt;Ctrl-C&amp;gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;STOP at line 40!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; _&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Line 10 declares a “pin variable” named “led1”, then configures the general purpose I/O pin “dtin0” for digital output, and finally binds the pin variable to the corresponding pin (in traditional BASIC, the “dim” statement is used to “dimension” the shape of a variable prior to use).&amp;nbsp; From then on, any modification of the pin variable is immediately reflected at the I/O pin.&amp;nbsp; Line 20 starts an infinite loop.&amp;nbsp; Line 30 inverts the state of the dtin0 digital output pin.&amp;nbsp; Line 40 delays the program for 500 ms.&amp;nbsp; And finally line 50 ends the infinite loop.&amp;nbsp; Press &amp;lt;Ctrl-C&amp;gt; to stop the program.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Of course, if you really *just* wanted to print “Hello world!” to the terminal (assuming it was still connected &lt;SPAN aria-label="Happy" class="emoticon_happy emoticon-inline" style="height:16px;width:16px;"&gt;&lt;/SPAN&gt;, you could just do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;10 print "Hello world!"&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;Hello world!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;_&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style=": ; font-size: 4;"&gt;Hello Accelerometer!!&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want to read analog input pins in StickOS BASIC, it’s just as easy...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To control and monitor the accelerometer on the M52221DEMO board, you could use the following program:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;10 dim x as pin an4 for analog input&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;20 dim y as pin an5 for analog input&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;30 dim z as pin an6 for analog input&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;40 dim gsel1 as pin utxd1 for digital output&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;50 dim gsel2 as pin urxd1 for digital output&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;60 dim wake as pin ucts1* for digital output&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;70 let gsel1 = 0&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;80 let gsel2 = 0&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;90 let wake = 1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;100 while 1 do&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;110&amp;nbsp; &amp;nbsp;print "x =", x, "; y =", y, "; z =", z&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;120&amp;nbsp; &amp;nbsp;sleep 1000&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;130 endwhile&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;x = 1583 ; y = 1656 ; z = 2456&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;x = 1576 ; y = 1662 ; z = 2458&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;x = 1593 ; y = 1655 ; z = 2465&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;x = 1572 ; y = 1656 ; z = 2455&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;lt;Ctrl-C&amp;gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;STOP at line 120!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;_&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lines 10-30 declare “pin variables” named “x”, “y”, and “z”, then configure I/O pins “an4”, “an5”, and “an6” for analog input, and finally bind the pin variables to the corresponding pins.&amp;nbsp; From then on, examination of the pin variables results in the current ADC values being read.&amp;nbsp; Lines 40-90 control the gsel1, gsel2, and wake (actually sleep*) pins of the accelerometer (see the M52221DEMO board schematic).&amp;nbsp; Lines 100-130 poll the accelerometer every second and print the results to the terminal, in millivolts (mV).&amp;nbsp; Press &amp;lt;Ctrl-C&amp;gt; to stop the program.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style=": ; font-size: 4;"&gt;Hello Toaster Oven!!!&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What if you want to use interrupts?&amp;nbsp; StickOS BASIC supports them also!&amp;nbsp; You can configure timers to interrupt periodically and UARTs to interrupt on character transmit or receive.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following program illustrates the use of a timer interrupt (at lines 50-60 and 130-190), and controls my toaster oven with a convenient SMT reflow temperature profile, when hooked to a K-type thermocouple thru a 100:1 op-amp!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;10 dim target, secs&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;20 dim thermocouple as pin an0 for analog input&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;30 dim relay as pin an1 for digital output&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;40 data 512, 90, 746, 105, 894, 20, -1, -1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;50 configure timer 0 for 1000 ms&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;60 on timer 0 gosub adjust&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;70 while target!=-1 do&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;80&amp;nbsp;&amp;nbsp; sleep secs*1000&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;90&amp;nbsp;&amp;nbsp; read target, secs&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;100 endwhile&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;110 let relay = 0&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;120 end&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;130 sub adjust&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;140&amp;nbsp;&amp;nbsp; if thermocouple&amp;gt;=target then&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;150&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; let relay = 0&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;160&amp;nbsp;&amp;nbsp; else&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;170&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; let relay = 1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;180&amp;nbsp;&amp;nbsp; endif&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;190 endsub&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;save&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;autorun on&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;autoreset on&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;reset&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that if terse code were our goal, lines 60 and 130-190 could have all been replaced with the single statement:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;60 on timer 0 let relay = thermocouple&amp;lt;target&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;“Save” saves the program to non-volatile flash memory, “autorun on” sets the program to run automatically when the CPUStick is powered up, and “autoreset on” sets the CPUStick to automatically reset itself when it is awakened from a sleep (as opposed to continuing running the saved BASIC program from where it left off).&amp;nbsp; Finally, “reset” resets the CPUStick as if it was just powered up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style=": ; font-size: 4;"&gt;Hello Dolly?!?&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using frequency output pins bound to the DMA timers whose value can be set in hertz (Hz), you can play scales or music or whatever else you might dream up, such as:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;10 dim oct&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;20 dim freq as pin dtin0 for frequency output&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;30 let freq = 440&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;40 for oct = 1 to 8&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;50&amp;nbsp;&amp;nbsp; sleep 500&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;60&amp;nbsp;&amp;nbsp; let freq = freq*105946/100000&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;70&amp;nbsp;&amp;nbsp; if oct!=3&amp;amp;&amp;amp;oct!=7 then&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;80&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; let freq = freq*105946/100000&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;90&amp;nbsp;&amp;nbsp; endif&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;100 next&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-family: 'Courier New';"&gt;&amp;gt; &lt;STRONG&gt;110 let freq = 0&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which plays a single octave of the musical scale starting at A-440 (Hz).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style=": ; font-size: 4;"&gt;Other StickOS features...&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* on-line help&lt;/P&gt;&lt;P&gt;* ansi terminal line editing&lt;/P&gt;&lt;P&gt;* transparent line-by-line compilation and de-compilation&lt;/P&gt;&lt;P&gt;* full-featured debugger with breakpoints, assertions, and even edit-and-continue&lt;/P&gt;&lt;P&gt;* load and save up to three BASIC programs in flash&lt;/P&gt;&lt;P&gt;* prolong flash lifetime by storing incremental updates in RAM&lt;/P&gt;&lt;P&gt;* StickOS firmware self-upgrade over USB&lt;/P&gt;&lt;P&gt;* MCU-to-MCU flash cloning over QSPI/EzPort&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style=": ; font-size: 4;"&gt;Who is StickOS for?&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Our main target audience for StickOS is folks doing low-volume hobbyist and educational work.&amp;nbsp; Or more specifically, our main target audience is folks for whom “ease of development” (and even ease of re-development!) is significantly more important than “production cost”.&amp;nbsp; Obviously, for hobbyist and educational use, there is no production!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style=": ; font-size: 4;"&gt;Who is StickOS *not* for?&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;StickOS simply doesn’t make sense for high-complexity, high-performance, high-volume, or cost-sensitive applications.&amp;nbsp; By pushing the development environment to the MCU, you end up using a $6 MCU where you could have gotten by with a $1 MCU, from a performance and resource usage perspective.&amp;nbsp; Likewise for high-volume applications, development costs (and “ease of development”) are nearly moot, since they are amortized over large number of production units.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style=": ; font-size: 4;"&gt;Where is more information on StickOS?&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See &lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.cpustick.com%2F" rel="nofollow" target="_blank"&gt;http://www.cpustick.com&lt;/A&gt; .&amp;nbsp; You can download the S19 ColdFire binary image to flash to your M52221DEMO board, as well as a full set of documentation.&amp;nbsp; There are also C source code examples for the “general purpose” parts of StickOS I thought folks would find useful, including the FTDI/USB transport device driver, S19 file parsing and self-upgrading, flash programming, QSPI/EzPort flash cloning, etc.&amp;nbsp; These source files are available with no restrictions; however, we ask you don’t republish them so we c an fix bugs in the originals.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The “CPUStick” part of the website is the other half of the equation for making these projects more accessible to high-school and college age hobbyists -- it is a small (0.9” by 1.8”) PCB with the MCF52221 running StickOS, with 0.1” header pins suitable for use in either a solderless breadboard or wirewrap environment.&amp;nbsp; You can download Gerber files if you want to make your own PCB.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For now, we can produce a limited number of CPUSticks for folks who want to help with beta test.&amp;nbsp; We are especially seeking educators!&amp;nbsp; Also, if you have other platforms you'd like us to port StickOS to, let us know that, too, as the code is easily portable!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-- Rich&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS The next project we’re just starting is to add a zigbee wireless daughter card (also 0.9” by 1.8”) based on the MC13201 to the CPUStick so you can remotely log in from one CPUStick to another, eliminating the need for the USB connection for all but the first CPUStick!&amp;nbsp; And we’ll add QSPI support to StickOS at the same time, since that’s the MC13201 interface.&amp;nbsp; I’m also considering a port to the (LQFP44) 51JM128, to save $2 and some board real estate.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Aug 2008 05:29:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Introducing-StickOS-BASIC-for-MCF52221-ColdFire-MCU-beta-long/m-p/179155#M7210</guid>
      <dc:creator>RichTestardi</dc:creator>
      <dc:date>2008-08-09T05:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: Introducing StickOS BASIC for MCF52221 ColdFire MCU (beta, long)...</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Introducing-StickOS-BASIC-for-MCF52221-ColdFire-MCU-beta-long/m-p/179156#M7211</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;If you do nothing else please do not use blue text on black background. I can' t read it.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 10 Aug 2008 05:56:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Introducing-StickOS-BASIC-for-MCF52221-ColdFire-MCU-beta-long/m-p/179156#M7211</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2008-08-10T05:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: Introducing StickOS BASIC for MCF52221 ColdFire MCU (beta, long)...</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Introducing-StickOS-BASIC-for-MCF52221-ColdFire-MCU-beta-long/m-p/179157#M7212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Hi JimDon,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;gt; If you do nothing else please do not use blue text on black background. I can' t read it.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I think using a black background at all&amp;nbsp;is just begging for trouble...&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I changed it.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;-- Rich&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 10 Aug 2008 10:16:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Introducing-StickOS-BASIC-for-MCF52221-ColdFire-MCU-beta-long/m-p/179157#M7212</guid>
      <dc:creator>RichTestardi</dc:creator>
      <dc:date>2008-08-10T10:16:39Z</dc:date>
    </item>
  </channel>
</rss>

