Shop OBEX P1 Docs P2 Docs Learn Events
Lesson #1 Propeller Question — Parallax Forums

Lesson #1 Propeller Question

LarryCardoLarryCardo Posts: 28
edited 2011-01-30 10:25 in Propeller 1
Using the book "Programming and Customizing the Multicore Propeller Microcontroller", I programmed the first exercise on page 23 and it worked OK (turned led #16 on). Using the Propeller Demo board I purchased in about 2009.

PUB LED_On

dira[16] := 1
dirb[16] := 1
repeat

LED 16 lit up.

Then I mistakenly changed the 1's to 3's.

PUB LED_On

dira[16] := 3
dirb[16] := 3
repeat

Now when ever I run the first program, no leds light up. However, when I press the reset, the leds sequentially flash for a second or 2. But then I loaded the first program into EEPROM and now when I hit reset no leds light?

Did I damage something?

Confused in Lesson 1,

Larry Cardo

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2011-01-29 18:12
    Whether you use dira[16] := 1 or dira[16] := 3 doesn't make a difference. As dira[16] is only a single bit the assigned value is limited to one bit as well, i.e. 3 & 1 = 1. So the issue is most likely somewhere else. Could you post your complete source please. Guessing doesn't get us anywhere fast.
  • LarryCardoLarryCardo Posts: 28
    edited 2011-01-29 18:38
    That was the complete source code.

    PUB LED_On

    dira[16] := 1
    dirb[16] := 1
    repeat

    Thanks for your review and explanation.
  • kuronekokuroneko Posts: 3,623
    edited 2011-01-29 18:42
    If you have a demoboard then you can turn on an LED with the following sequence:
    dira[16] := 1
    [COLOR="red"]outa[/COLOR][16] := 1
    repeat
    
    Does this still work?
  • LarryCardoLarryCardo Posts: 28
    edited 2011-01-29 19:02
    Kuroneko,

    You solved it. I had a stupid typo. Instead of using "outa[16] : =1, i used dirb[16] := 1.

    This is going to be a long trip to AI!

    Larry
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-01-30 01:32
    It's interesting to note, DIRB is reserved for the next set of pins that will be on the future Propeller 2. Therefore Port B is for pins 32 to 63 on the future Prop 2. See page 104 in the Propeller Manual for more information. DIRA is for pins 0 to 31 on the Prop 1. The typo is a good learning experience and can expand your knowledge of the Propeller chip.
  • LarryCardoLarryCardo Posts: 28
    edited 2011-01-30 10:25
    Thanks Humanoido,

    It is a good lesson, but I have been programming since the mid 60's. Duh!

    I am enjoying your "Fill the Big Brain" series. When do you work or sleep?

    Larry
Sign In or Register to comment.