Propeller SPIN Blink an LED
microcontrolleruser
Posts: 1,194
We're going in!
Using Prop Pro board. Grey one. Revision A maybe.
Will start looking for lesson for that.
If nothing else I know there is one in PEKit Fundamentals text.

Comments
Using Propeller Tool compiler.
Reading this from Help section.
About the Propeller Chip Hardware
Says to read it and How the Propeller Tool Works before blinking an LED.
Got the Prop Pro board out. Will look for a power supply. Think it can take up to a 12v.Stamp boards are only up to 7.5
Found Blink an LED program in Prop Tool Help tutorial.
Should have that LED blinking soon!
There's a product page for the Propeller Professional Development Board (PPDB) on the main Parallax website. That should give the power supply requirements.
Okay.
I will make Pro Board manual an icon on desktop.
It used to be a download at bottom of product page.
EDIT
Have the manual version 1.0 for grey Pro Board.
Using BOEBot battery pack 6v. It doesn't have cord to trip over.
Do not "make the Pro Board manual on icon". Print it out. Using your printer. On Paper. It is only 3 sheets (double-sided). Print out the schematic as well. Go study them. Say for at least an entire hour. Then ask more questions.
Tom
Have an observation and a question.
Wasn't paying attention and the first source code says right on it 'Lesson 2'.
Lesson 1 explains some stuff.
Says when you put objects in an application it compiles.
So Propeller tool does compile at some point but interprets when it just a snippet of code?
PUB main COGINIT(COGID,@start,0) {The 0 gets put in PAR register of new cog} DAT {Assembly program starts at 0} org 0 start:Mike
Yep. Like a template. Thanks.
Here's a picture of Pro Board.
It came out upside down.
Daisy chained from PIN 16 to LED. Too lazy to find long jumper wires.
Can you explain that a different way please? EDIT I mean about the Prop. Our posts crossed.
A PIC you do like this:
Compile code to hex.
Download hex to PIC.
It starts running immediately when it is powered up.
Can you just say the first thing Propeller tool does?
Maybe that will clear it up.
Mike
Just to help out I read Help.
If you have a snippet and load to RAM it works like a PIC.
More or less.
Think there is that 'compiles to "interpreter code" ' not hex wrinkle.
This is leaving out 'COG's'. Stuff about moving 'your program' from hub to cog.
Tom
That's the 'still photo studio'.
12" x 24" piece of ceiling tile from Home Depot.
Yes. We do use a power supply and a USB cable.
The chip powers up or the reset line is allowed to go high.
The bootloader is started (from masked ROM on-chip) by loading it into cog 0 RAM
The bootloader looks for a serial port on I/O pins 30/31 (pin 31 high)
... if present, negotiates Baud with PC and downloads program to hub RAM
... if successful download, starts Spin interpreter in cog 0 on hub RAM contents
The bootloader looks for I2C EEPROM on I/O pins 28/29
... if present, copies 1st 32K of EEPROM to hub RAM
... if checksum correct, starts Spin interpreter in cog 0 on hub RAM contents
If the Spin program in hub RAM contains some assembly code, it (the Spin code) will
eventually execute one or more COGNEW or COGINIT statements which will be interpreted
and execute the equivalent COGINIT instruction that will copy a block of hub memory into a
cog and start that cog running from cog location 0 with that cog's special registers
(memory mapped) initialized to zero (except PAR which is initialized from the COGINIT).
It just repeats the same message.
Ignore the commented out sections using single or double braces.
{Blink a LED} CON _clkmode = xtal1 + pll16x 'Standard clock mode _xinfreq = 5_000_000 '* crystal frequency = 80 MHz MyLED = 26 'pin connected to a LED via a resistor PUB BeginHere dira[MyLed] := 1 'set direction repeat 'forever outa[MyLed] := 1 'set it high waitcnt(clkfreq + cnt) 'one second outa[MyLed] := 0 'low waitcnt(clkfreq/2 + cnt) 'one-half secondSo here one is.
Tom
Thanks. It was in one of my posts.
Propeller Tool/Help/Tutorial/Exercise 3. There is no Exercise 1 or 2 source code.
BTW Just 'Detected Device' about to compile and run.
It blinks!
Think I am going to take some time to savor the moment.
To run on the slower Internal RC oscillator, remove the _clkmode and _xinfreq lines.
Blink ten times with each time different off period.
CON _clkmode = xtal1 + pll16x 'Standard clock mode _xinfreq = 5_000_000 '* crystal frequency = 80 MHz MyLED = 26 'pin connected to a LED via a resistor PUB main oneSec := CLKFREQ { Initialize "constants" in assembly code } halfSec := CLKFREQ/2 COGINIT(COGID,@start,0) { Doesn't return. Assembly starts in same cog } { Note that the wait times are relative to the fetch of the CNT value just before loop:. waits after that (using waitcnt) are still relative to the initial fetch of the time. This allows very precise timing relative to specific events including precise synchronization to external (or internal) events. } DAT {Assembly program starts at 0} org 0 start or dira,MyLEDMask { dira[MyLED] := 1 } mov timeCnt,oneSec { one second delay } add timeCNT,CNT { compute relative to current time } loop or outa,MyLEDMask { outa[MyLED] := 1 } waitcnt timeCNT,halfSec { wait for 1 second and setup for 1/2 second } andn outa,MyLEDMask { outa[MyLED] := 0 } waitcnt timeCNT,oneSec { wait for 1/2 second and setup for 1 second } jmp #loop { jump addresses must be immediate values } MyLEDMask long 1 << MyLED { bitmask for MyLED } timeCnt long 0 { temp variable for WAITCNT } oneSec long 0 { clock ticks per second } halfSec long 0 { clock ticks per half second }(corrected and tested on Activity Board)Mike
Thank you for doing that.
Actually going to bounce over to Stamp 1 Stepper project.
I am a lightweight around here. Not one of the heavyweights that can knock out the code.
Plus build hardware at will.
I'm just one of the 'little guys'.
Mike
Appreciate it!
You will have to pull the weight around here.
Long sessions at the workbench with the soldering iron and schematics.
Coding for hours with a box of pizza and sodas.