CON
_clkmode = xtal1 + pll16x 'Standard clock mode * crystal frequency = 80 MHz
_xinfreq = 5_000_000
a=111
VAR
long symbol
pub sky
dira[0..4]~~
repeat
outa[a]
'the outa[a] line doesn't want to compile, I was going to use many combinations of [0..4] so assigning each state in the con to a single letter would save time. In the con section it should read : a=111(for some reason when I edit the reply it goes back to a=111)
No, you don't use a colon in front of the equal sign. "a" is the name of a constant and you just write "a = %111". Note that you forgot the "%", so the value of "a" was one hundred and eleven which is an invalid pin number, thus the error message when you wrote "outa[ a ]".
CON
_clkmode = xtal1 + pll16x 'Standard clock mode * crystal frequency = 80 MHz
_xinfreq = 5_000_000
a=111
VAR
long symbol
pub sky
dira[0..4]~~
repeat
outa[a]
'the outa[a] line doesn't want to compile, I was going to use many combinations of [0..4] so assigning each state in the con to a single letter would save time. In the con section it should read : a=111(for some reason when I edit the reply it goes back to a=111)
As Mike stated your CON section needs to state " a = percent-sign111" <== Note to post readers: the web editor for the forum turns the percent sign and 2 following '1's to a null character...
But, the real error "may" be that you are not actually setting the outa register with your code: "outa[a]"...
Don't you need to do something like "outa[a]~" to set the pins low and "outa[a]~~" to set them high?
I get the following error in SimpleIDE when I try to compile your code:
CON
_clkmode = xtal1 + pll16x 'Standard clock mode * crystal frequency = 80 MHz
_xinfreq = 5_000_000
a = percent-sign111 ' <== replace "percent-sgn" with % for the forum editor
VAR
long symbol
pub sky
dira[0..4]~~
repeat
outa[a]~~ ' needs an operator! (could use: outa[a] := 1, as well)
which sets bits 0-2 to high...
I think we were all confused by the web editor's policy of reformatting the percent-sign characters when preceding the 1111's
What's not clear to me is whether mikea wants to set the bit mask as a constant or the pin numbers as a constant.
My second example in post #2 sets both the pins used and the bit mask as constants. My verbose constant names could be changed to single letter names to better match mikea's original request. I didn't use single letter constants since I personally very much dislike single letter variable and constant names.
In general I try to make variable and constant names long enough a ctrl-f search will find only the name I'm looking for and not sections of other names.
BTW, The percent sign issue can be fixed by using switching to the "Basic Editor". From your profile select "Settings" (top right of screen), then select "General Settings" (under "My Settings"\"My Account" on the left side of the screen). Under "Miscellaneous Options" select "Basic Editor - A simple text box" ("Miscellaneous Options" is the last section of the "General Settings" page).
The Basic Editor can be a pain to use when you want to add pictures, links or video, so you may want to switch back to "Enhanced Interface - Full WYSIWYG Editing" after you've posted your code. The Basic Editor doesn't have the code "#" button in the advanced editor so you'll need to type out the code tags yourself.
What's not clear to me is whether mikea wants to set the bit mask as a constant or the pin numbers as a constant.
My second example in post #2 sets both the pins used and the bit mask as constants. My verbose constant names could be changed to single letter names to better match mikea's original request. I didn't use single letter constants since I personally very much dislike single letter variable and constant names.
In general I try to make variable and constant names long enough a ctrl-f search will find only the name I'm looking for and not sections of other names.
BTW, The percent sign issue can be fixed by using switching to the "Basic Editor". From your profile select "Settings" (top right of screen), then select "General Settings" (under "My Settings"\"My Account" on the left side of the screen). Under "Miscellaneous Options" select "Basic Editor - A simple text box" ("Miscellaneous Options" is the last section of the "General Settings" page).
The Basic Editor can be a pain to use when you want to add pictures, links or video, so you may want to switch back to "Enhanced Interface - Full WYSIWYG Editing" after you've posted your code. The Basic Editor doesn't have the code "#" button in the advanced editor so you'll need to type out the code tags yourself.
Ah yes, it is a bit unclear what is needed versus what was asked.
Yes, variable names should have meaning and allow easy search...
Thanks for the info on the percent sign and using the basic editor, as I've had several posts that required special characters.
Thanks guys, I am trying to set a bit mask as a constant to turn on/off a row of leds to save repeated typing and maybe a mistake when putting this info in the code. In post 2 there is an example. Is there a simpler way to set them? I've tried a:=outa[0..3]:=[percent 0101] and put "a" as a variable, and other ways but they won't compile. The compiler says I need an operator.
Thanks guys, I am trying to set a bit mask as a constant to turn on/off a row of leds to save repeated typing and maybe a mistake when putting this info in the code. In post 2 there is an example. Is there a simpler way to set them? I've tried a:=outa[0..3]:=[percent 0101] and put "a" as a variable, and other ways but they won't compile. The compiler says I need an operator.
How about making your outa statement a method?
PUB Main
repeat
'do stuff
A
'do other stuff
PUB A
outa[0..3]:= %0101
Then whenever you type "A" you get the pins set the way you want.
Comments
The above would set pins 0, 1 and 2 as outputs.
If you also want the bit mask to be a constant you could do something like this:
The above would set pins 1 and 2 as outputs.
Edit: As with many programming tasks there are many ways to do this. A pin mask could be bitwise "or"ed to the dira register to set desired pins high.
now my head hurts...
-Tommy
As Mike stated your CON section needs to state " a = percent-sign111" <== Note to post readers: the web editor for the forum turns the percent sign and 2 following '1's to a null character...
But, the real error "may" be that you are not actually setting the outa register with your code: "outa[a]"...
Don't you need to do something like "outa[a]~" to set the pins low and "outa[a]~~" to set them high?
I get the following error in SimpleIDE when I try to compile your code:
So changed the code to:
which sets bits 0-2 to high...
I think we were all confused by the web editor's policy of reformatting the percent-sign characters when preceding the 1111's
dgately
My second example in post #2 sets both the pins used and the bit mask as constants. My verbose constant names could be changed to single letter names to better match mikea's original request. I didn't use single letter constants since I personally very much dislike single letter variable and constant names.
In general I try to make variable and constant names long enough a ctrl-f search will find only the name I'm looking for and not sections of other names.
BTW, The percent sign issue can be fixed by using switching to the "Basic Editor". From your profile select "Settings" (top right of screen), then select "General Settings" (under "My Settings"\"My Account" on the left side of the screen). Under "Miscellaneous Options" select "Basic Editor - A simple text box" ("Miscellaneous Options" is the last section of the "General Settings" page).
The Basic Editor can be a pain to use when you want to add pictures, links or video, so you may want to switch back to "Enhanced Interface - Full WYSIWYG Editing" after you've posted your code. The Basic Editor doesn't have the code "#" button in the advanced editor so you'll need to type out the code tags yourself.
Ah yes, it is a bit unclear what is needed versus what was asked.
Yes, variable names should have meaning and allow easy search...
Thanks for the info on the percent sign and using the basic editor, as I've had several posts that required special characters.
I generally type in the code tags anyway!
Thanks Duane!
dgately
How about making your outa statement a method?
Then whenever you type "A" you get the pins set the way you want.