SPI byref calls
-
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
SPI byref calls
So far I have been having a pretty good luck with ARMmite up until
now. I'm trying to read data form an external A/D converter using the
SPIIN command but apparently I don't understand the syntax and I can't
find much of any support for it. I'm just trying to read a 12-bits of
data in MSB mode but the code won't compile. Here is what I have been
trying;
DIM INlist As String
SPIIN (-1, 13, 12, -1, -1, 0, "", 12, BYREF INlist AS STRING)
print INlist
But when I try to load the program it tells me;
" DIM INlist As String
-ERROR In Line SIMPLE~1.BAS: 27: Syntax error in declaration, found
String
SPIIN (-1, 13, 12, -1, -1, 0, "", 12, BYREF INlist AS STRING)
-ERROR In Line SIMPLE~1.BAS: 28: Expected string variable, found
BYREF INlist AS STRING)
SPIIN (-1, 13, 12, -1, -1, 0, "", 12, BYREF INlist AS STRING)
-ERROR In Line SIMPLE~1.BAS: 28: Expected End Of Line, found BYREF
INlist AS STRING)
print INlist
-ERROR In Line SIMPLE~1.BAS: 29: Undefined Label INLIST
print INlist
-ERROR In Line SIMPLE~1.BAS: 29: Expected Function Integer IO Or
Variable, found INlist
print INlist
-ERROR In Line SIMPLE~1.BAS: 29: Expected End Of Line, found INlist
?? print INlist
-First ERROR at line :27
"
I've tried a lot of different declarations and such but I can't seem
to get it to work. What am I doing wrong? Is there more literature or
some examples using the SPIIN command other than whats in the ARMHelp?
now. I'm trying to read data form an external A/D converter using the
SPIIN command but apparently I don't understand the syntax and I can't
find much of any support for it. I'm just trying to read a 12-bits of
data in MSB mode but the code won't compile. Here is what I have been
trying;
DIM INlist As String
SPIIN (-1, 13, 12, -1, -1, 0, "", 12, BYREF INlist AS STRING)
print INlist
But when I try to load the program it tells me;
" DIM INlist As String
-ERROR In Line SIMPLE~1.BAS: 27: Syntax error in declaration, found
String
SPIIN (-1, 13, 12, -1, -1, 0, "", 12, BYREF INlist AS STRING)
-ERROR In Line SIMPLE~1.BAS: 28: Expected string variable, found
BYREF INlist AS STRING)
SPIIN (-1, 13, 12, -1, -1, 0, "", 12, BYREF INlist AS STRING)
-ERROR In Line SIMPLE~1.BAS: 28: Expected End Of Line, found BYREF
INlist AS STRING)
print INlist
-ERROR In Line SIMPLE~1.BAS: 29: Undefined Label INLIST
print INlist
-ERROR In Line SIMPLE~1.BAS: 29: Expected Function Integer IO Or
Variable, found INlist
print INlist
-ERROR In Line SIMPLE~1.BAS: 29: Expected End Of Line, found INlist
?? print INlist
-First ERROR at line :27
"
I've tried a lot of different declarations and such but I can't seem
to get it to work. What am I doing wrong? Is there more literature or
some examples using the SPIIN command other than whats in the ARMHelp?
-
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: SPI byref calls
>
> DIM INlist As String
> SPIIN (-1, 13, 12, -1, -1, 0, "", 12, BYREF INlist AS STRING)
> print INlist
>
> But when I try to load the program it tells me;
>
> " DIM INlist As String
> -ERROR In Line SIMPLE~1.BAS: 27: Syntax error in declaration, found
> String
Unless I'm wrong, ARMbasic follows the VB syntax.
The declaration of BYREF is done in the function, not when called. I
don't think there is a way to override that (if there is a VB way to do
that someone enlighten me)
Your call should be--
SPIIN (-1, 13, 12, -1, -1, 0, "", 12, INlist)
> DIM INlist As String
> SPIIN (-1, 13, 12, -1, -1, 0, "", 12, BYREF INlist AS STRING)
> print INlist
>
> But when I try to load the program it tells me;
>
> " DIM INlist As String
> -ERROR In Line SIMPLE~1.BAS: 27: Syntax error in declaration, found
> String
Unless I'm wrong, ARMbasic follows the VB syntax.
The declaration of BYREF is done in the function, not when called. I
don't think there is a way to override that (if there is a VB way to do
that someone enlighten me)
Your call should be--
SPIIN (-1, 13, 12, -1, -1, 0, "", 12, INlist)
-
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: SPI byref calls
--- In ARMexpress@yahoogroups.com, "basicnode" <bruce@...> wrote:
>
> >
> > DIM INlist As String
> > SPIIN (-1, 13, 12, -1, -1, 0, "", 12, BYREF INlist AS STRING)
> > print INlist
> >
> > But when I try to load the program it tells me;
> >
> > " DIM INlist As String
> > -ERROR In Line SIMPLE~1.BAS: 27: Syntax error in declaration, found
> > String
>
> Unless I'm wrong, ARMbasic follows the VB syntax.
>
> The declaration of BYREF is done in the function, not when called. I
> don't think there is a way to override that (if there is a VB way to do
> that someone enlighten me)
>
> Your call should be--
>
> SPIIN (-1, 13, 12, -1, -1, 0, "", 12, INlist)
>
Ok, after an hour of frustration I figure it out. I have tried the
call you had posted basicnode, it is very close but exact. It needs
the quotation marks around INlist so its;
SPIIN (-1, 13, 12, -1, -1, 0, "", 12, "INlist")
>
> >
> > DIM INlist As String
> > SPIIN (-1, 13, 12, -1, -1, 0, "", 12, BYREF INlist AS STRING)
> > print INlist
> >
> > But when I try to load the program it tells me;
> >
> > " DIM INlist As String
> > -ERROR In Line SIMPLE~1.BAS: 27: Syntax error in declaration, found
> > String
>
> Unless I'm wrong, ARMbasic follows the VB syntax.
>
> The declaration of BYREF is done in the function, not when called. I
> don't think there is a way to override that (if there is a VB way to do
> that someone enlighten me)
>
> Your call should be--
>
> SPIIN (-1, 13, 12, -1, -1, 0, "", 12, INlist)
>
Ok, after an hour of frustration I figure it out. I have tried the
call you had posted basicnode, it is very close but exact. It needs
the quotation marks around INlist so its;
SPIIN (-1, 13, 12, -1, -1, 0, "", 12, "INlist")
-
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: SPI byref calls
> Ok, after an hour of frustration I figure it out. I have tried the
> call you had posted basicnode, it is very close but exact. It needs
> the quotation marks around INlist so its;
>
> SPIIN (-1, 13, 12, -1, -1, 0, "", 12, "INlist")
>
I don't think this is going to do what you want it to. Even if it
compiles, it will probably cause a DataAbort, as you would be trying to
write into the Flash space where the constant string you defined is,
that constant string is "INlist" not the variable string declared
INlist.
You can always look at the BASIC library source, contained in BASIClib
directory
SUB SPIIN (CSpin, INpin, CLKpin, OUTpin, LSBfirst, OUTcnt, BYREF
OUTlist as STRING, INcnt, BYREF INlist as STRING)
> call you had posted basicnode, it is very close but exact. It needs
> the quotation marks around INlist so its;
>
> SPIIN (-1, 13, 12, -1, -1, 0, "", 12, "INlist")
>
I don't think this is going to do what you want it to. Even if it
compiles, it will probably cause a DataAbort, as you would be trying to
write into the Flash space where the constant string you defined is,
that constant string is "INlist" not the variable string declared
INlist.
You can always look at the BASIC library source, contained in BASIClib
directory
SUB SPIIN (CSpin, INpin, CLKpin, OUTpin, LSBfirst, OUTcnt, BYREF
OUTlist as STRING, INcnt, BYREF INlist as STRING)
-
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: SPI byref calls
I went back and looked at your original post.
> DIM INlist As String
Yes this declares INlist as a string, but it has no size,so it will
probably be 4 bytes long. (3 available to you)
So your read of 12 bytes into it will clobber whatever variable you
declared after it, if it worked at all.
Yup, the compiler should have flagged the INlist without a range as an
error. And that will get added to the to do list. Its pretty hard to
figure out all possible errors.
> DIM INlist As String
Yes this declares INlist as a string, but it has no size,so it will
probably be 4 bytes long. (3 available to you)
So your read of 12 bytes into it will clobber whatever variable you
declared after it, if it worked at all.
Yup, the compiler should have flagged the INlist without a range as an
error. And that will get added to the to do list. Its pretty hard to
figure out all possible errors.
-
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: SPI byref calls
>
> I went back and looked at your original post.
>
> > DIM INlist As String
>
> Yes this declares INlist as a string, but it has no size,so it will
> probably be 4 bytes long. (3 available to you)
>
> So your read of 12 bytes into it will clobber whatever variable you
> declared after it, if it worked at all.
>
> Yup, the compiler should have flagged the INlist without a range as an
> error. And that will get added to the to do list. Its pretty hard to
> figure out all possible errors.
>
Thanks for the replies basicnode. Yes, you are right it didn't do what
I wanted it to and caused a Data Abort error. I've tried making INcnt
0 and it still didn't work. I'm out of the lab right now so I'll give
it another try tomorrow morning. Thanks again.
> I went back and looked at your original post.
>
> > DIM INlist As String
>
> Yes this declares INlist as a string, but it has no size,so it will
> probably be 4 bytes long. (3 available to you)
>
> So your read of 12 bytes into it will clobber whatever variable you
> declared after it, if it worked at all.
>
> Yup, the compiler should have flagged the INlist without a range as an
> error. And that will get added to the to do list. Its pretty hard to
> figure out all possible errors.
>
Thanks for the replies basicnode. Yes, you are right it didn't do what
I wanted it to and caused a Data Abort error. I've tried making INcnt
0 and it still didn't work. I'm out of the lab right now so I'll give
it another try tomorrow morning. Thanks again.
-
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: SPI byref calls
I noticed that the example in our helpfile was an older version and
needs updating. PLEASE, PLEASE let us know about these type of issues
so that we can correct them.
For an extensive SPI example take a look at the excellent work from
MicroMega interfacing to their Floating Point Chip via both SPI and i2c
http://www.micromegacorp.com/downloads/ ... asicV7.zip
unzip it and look at FPUspi.bas
needs updating. PLEASE, PLEASE let us know about these type of issues
so that we can correct them.
For an extensive SPI example take a look at the excellent work from
MicroMega interfacing to their Floating Point Chip via both SPI and i2c
http://www.micromegacorp.com/downloads/ ... asicV7.zip
unzip it and look at FPUspi.bas
-
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: SPI byref calls
I followed your advice and looked at the example and I managed to get
something to compile but not quiet work. I'm not picking up any signal
on the Oscope from the clock pin so nothing is transferring form the
AD. I'm still messing with but hopefully I just connected something
wrong.
something to compile but not quiet work. I'm not picking up any signal
on the Oscope from the clock pin so nothing is transferring form the
AD. I'm still messing with but hopefully I just connected something
wrong.
-
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: SPI byref calls
I still can not get the clock to work using SPIIN command. No matter
what I do and what pin I try it simply will not work. I was able to
create a manual clock using HWPWM and got the AD converter to output a
byte but the controller wont read it. I've tried I2C as well to no
avail and am stuck at this point. I might try using SERIN tomorrow
even though the command is to slow for my application.
what I do and what pin I try it simply will not work. I was able to
create a manual clock using HWPWM and got the AD converter to output a
byte but the controller wont read it. I've tried I2C as well to no
avail and am stuck at this point. I might try using SERIN tomorrow
even though the command is to slow for my application.
-
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: SPI byref calls
I should have caught this before. As listed in the Hardware Pin
diagram for the ARMmite. IOs 12 and 13 are open drain. This means
you need a pullup resistor on those pins to get them to go high.
Whenever I see a pin not wiggling, I test it with a simple loop to
check wiring etc.
for i=1 to 50
io(13) = i and 1
wait (500)
next i
diagram for the ARMmite. IOs 12 and 13 are open drain. This means
you need a pullup resistor on those pins to get them to go high.
Whenever I see a pin not wiggling, I test it with a simple loop to
check wiring etc.
for i=1 to 50
io(13) = i and 1
wait (500)
next i