Error 101: too many parameters

Help
Jonoe
2009-04-01
2013-03-12
  • Jonoe
    Jonoe
    2009-04-01

    Hello,

    I am having troubles with the compilation of an application in SDCC. I've created a function called spi_writeb. Function code is the next:

    void spi_writeb(uint8_t byte)
    {
    U1BUF=byte;
    while((U1CSR & U_ACTIVE));
    }

    In the main function I wrote:

    spi_writeb(Xdata);

    Xdata was already declared as a volatile uint8_t.

    Compiler showed me the error message 101: too many parameters. How can I solve the problem?
    Thanks

     
    • Maarten Brock
      Maarten Brock
      2009-04-02

      Insert a prototype of spi_writeb before you call it or define the function first.

       
      • Hi,

        in this case it might also be attractive to use a macro:

        -----------8<---------------------------------------------------------
        #include <cc2430.h>
        #define U_ACTIVE (0x01)

        SBIT (U1CSR_ACTIVE, 0xf8, 0);

        #define SPI_WRITEB(x) do{U1DBUF=(x); while((U1CSR & U_ACTIVE));} while(0)
        #define SPI_WRITEC(x) do{U1DBUF=(x); while(U1CSR_ACTIVE);} while(0)

        void spi_writeb(unsigned char byte)
        {
            U1DBUF=byte;
            while((U1CSR & U_ACTIVE));
        }

        void main(void)
        {
            spi_writeb(0xab);
            SPI_WRITEB(0xcd);
            SPI_WRITEC(0xcd);
        }
        --------->8---------------------------------------------------------

        -----------8<-------------------------------------------------------
                                    890 ;       spi_ti.c:17: spi_writeb(0xab);
           0009 75 82 AB            891         mov     dpl,#0xAB
           000C 12s00r00            892         lcall   _spi_writeb
                                    893 ;       spi_ti.c:18: SPI_WRITEB(0xcd);
           000F 75 F9 CD            894         mov     _U1DBUF,#0xCD
           0012                     895 00101$:
           0012 E5 F8               896         mov     a,_U1CSR
           0014 20 E0 FB            897         jb      acc.0,00101$
                                    898 ;       spi_ti.c:19: SPI_WRITEC(0xcd);
           0017 75 F9 CD            899         mov     _U1DBUF,#0xCD
           001A                     900 00107$:
           001A 20 F8 FD            901         jb      _U1CSR_ACTIVE,00107$
        ----------->8-------------------------------------------------------

        Note, you are polling for bit U_ACTIVE in U1CSR which is bit addressable.
        The macro SPI_WRITEC(x) makes use of this.

        Greetings,
        Frieder

        PS: white spaces in this post might be garbled by sourceforge. sorry.
        And sourceforge uses a proportional font which makes postings like these hardly readable. sorry.