Simple asm to turn on LED
Rsadeika
Posts: 3,837
Today I downloaded the ICC, just to see what the program was like. I looked at the example for turning on an LED, which looked like it was simple enough to understand, so I decide to give pasm a try, and code a simple LED program. Oh, BTW, I looked at the example that was in the manual, and I got stumped on the bitwise decode for the Pin declaration. So, my first attemp is a complete failure, the code below should turn the LED, by my understanding,·on, that is connected to pin 7, but it does not, what am I missing here?
CON
PUB Main
· cognew(@Toggle, 0)
DAT
····· org 0
Toggle
· mov dira, Pin·· 'Initialise the pin
· mov outa, 1··· 'Set the pin to high(turn the pin on)
·
Pin long 7·········'I guess this would be the pin declaration
Thanks
Ray
CON
PUB Main
· cognew(@Toggle, 0)
DAT
····· org 0
Toggle
· mov dira, Pin·· 'Initialise the pin
· mov outa, 1··· 'Set the pin to high(turn the pin on)
·
Pin long 7·········'I guess this would be the pin declaration
Thanks
Ray
Comments
Declaring Pin as 7 would in fact set bits 0..2 and declare all three of them as outputs.
This code below also makes sense, but turns on pin six also:
[noparse][[/noparse]code]
CON
PUB Main
· cognew(@Toggle, 0)
DAT
····· org 0
Toggle
· mov···· dira, Pin·· 'Initialise the pin
· mov··· ·outa, Pin·· 'Set the pin to high(turn the pin on)
backhere
··jmp··· ·#backhere
' you'll need something like this as·otherwise the cog will execute code after the mov outa,Pin
' don't know off hand without looking it up, what the 1<<7 would do, lol
' and not to mention if you add anything·after that,
' like·more data for other things and/or more code.
·
Pin··· long··· 1 << 7
[noparse][[/noparse]/code]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite
·
My first lesson was quite good, I learned two different ways of using code to turn on an LED, I am sure that their are more ways. And I also learned about the hardware side, make sure you do not have any wires that could possibly touch, or are touching. Which also could explain why on some of my other breadboard projects, I had some weird stuff occuring.
Now, that I have base of knowledge, I shall expand on this. Maybe some of my existing Spin code, in some of my other programs, can be tweaked by using some converting to pasm. I guess I will have to put ICC on the backburner while I explore pasm some more.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite
·
Without getting into convoluted code which is really only one of the following, I can only think of three ways ...