Shop OBEX P1 Docs P2 Docs Learn Events
Union in SPIN — Parallax Forums

Union in SPIN

wadiprawitawadiprawita Posts: 7
edited 2008-10-06 23:30 in Propeller 1
Dear All,

I'm new in Propeller programming, ans still waiting my Starter Kit to come.

One of the task I want to to do with Propeller is parsing uBlox GPS receiver bunary data. I have done this using other mCU using C. The trick is using Union (array of bytes and GPS data struct). I know that we can use DAT declaration with different alignment and type, but I read somewhere that it can not be done using float / single data type (and I can not check this, since I haven't had my hardware [noparse]:)[/noparse] ).

My question are :

1. Is there any union like implementation in SPIN ?
2. Is there anyway that I can make pointer assignment between float / single and array of byte ?
3. Is there any pointer reference for SPIN ?

Regards

-doni-

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2008-10-05 02:56
    hello,

    1.) No. the maximum that SPIN offers are ONE-dimensional arrays of byte, word, long (32bit)
    Floating-point values can be used by math-objects. There every calculation has to be done
    via method-calls. No simple FloatVarA + FloatVarB

    2.) If you program the details with the things mentioned in 1.) yes

    3.) Yes. There is the "@"-operator to get the adress of variables.


    The complexity of SPIN is lower than C, because the SPIN-interpreter has to fit into 2kB of cog-RAM. (organized as 496 PASM-longs)
    Nevertheless it offers great oportunities to develop communication with the user combined with
    programming very close to the hardware of the chip.

    Image-Craft offers a C-compiler for the propeller. I never look at it, because to me SPIN is enough for my demands.
    If you want to program it in SPIN. YOu have to program it new on the level that SPIN offers.

    best regards

    Stefan
  • wadiprawitawadiprawita Posts: 7
    edited 2008-10-05 06:24
    Thank's Stefan,

    Unfortunately the ICCV7 demo for Propelles does not support float right ?

    It doesn't even compile the following code :

    #include <stdio.h>
    #include <stdarg.h>
    #include <float.h>
    #include "asio.h"

    main() {
    float A;

    A = 1.0;
    }

    here are the error codes :

    C:\PROGRA~1\ICCV7P~1\bin\imakew -f HELLO.mak
    iccprop -c -e -D__ICC_VERSION="7.03" -DP8X32A -l -g -Wf-NoFcache ..\..\..\..\..\PROGRA~1\iccv7prop\examples.prop\printf\hello.c
    !W C:\PROGRA~1\iccv7prop\examples.prop\printf\hello.c(11):[noparse][[/noparse]warning] missing return value
    (108dbd8->op=ASGNF4 at C:\PROGRA~1\iccv7prop\examples.prop\printf\hello.c(10) is corrupt.)
    (code generator internal error 108dbd8->op=ASGNF4 at C:\PROGRA~1\iccv7prop\examples.prop\printf\hello.c(10), nt 1, no matching rule)
    !X The compiler has failed an internal consistency check. This may be due
    to incorrect input or an internal error. Please report the information
    0 at ..\gen.c(328) to "ImageCraft" support@imagecraft.com
    C:\PROGRA~1\ICCV7P~1\bin\imakew.exe: Error code 1
    Done: there are error(s). Exit code: 1. Sun Oct 05 13:15:21 2008

    Regards

    -doni-
  • StefanL38StefanL38 Posts: 2,292
    edited 2008-10-05 13:27
    hello doni,

    if you expected the comfort of an ARM-C-compiler SPIN is less than that.
    Hwo much the Image-craft C-compiler can do - I don't know. because i never used it.
    From my little experience with arm7 gcc I think each platform has it's own specialities you have to learn.

    In my opinion most c-developmentsystems are VERY complex. To me it looks almost like another includefile for every little blurp

    best regards

    Stefan
  • wadiprawitawadiprawita Posts: 7
    edited 2008-10-06 23:30
    I email Imagecraft,

    and here is the reply :

    "Float is currently not yet supported, but should be supported by the
    end of Oct, but only for the STD version..."

    Regards

    -doni-
Sign In or Register to comment.