Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

error 12 called objet is not a function

Help
2014-04-28
2014-05-01
  • alejandro1957
    alejandro1957
    2014-04-28

    It is the error.
    Thank you.
    I'm learning a little at a time.Thank you again.
    Should create a WORD long with two integer variables they read MSB and LSB of the response form for each axis.
    Axis = (MSB << 8) | LSB

     
  • alejandro1957
    alejandro1957
    2014-04-28

    yet another question.
    there is a function Atan2 at SDCC?

     
  • Raphael Neider
    Raphael Neider
    2014-04-29

    There is only the float variant atan2f() available; double support is probably not available for pic14. To make user of this library routine, you need to link with libm.lib, e.g., by using

    sdcc (options) (file names) -lm

    Note that devices with enhanced cores (those that link with libsdcce.lib rather than libsdcc.lib) need to link with libme.lib instead of libm.lib and thus need to use -lme instead of -lm.

     
    • alejandro1957
      alejandro1957
      2014-05-01

      thanks.
      to conclude.
      how can I send a long value with the sign through a serial port.
      in GCBasic was StrPrint function to convert a long value into a string.
      thanks in advance.

       
      • -----BEGIN PGP SIGNED MESSAGE-----
        Hash: SHA1

        On 01.05.2014 19:56, alejandro1957 wrote:

        thanks. to conclude. how can I send a long value with the sign
        through a serial port. in GCBasic was StrPrint function to convert
        a long value into a string. thanks in advance.

        snprintf() or similar an be used to onvert a long into a string.

        Philipp

        -----BEGIN PGP SIGNATURE-----
        Version: GnuPG v1
        Comment: Using GnuPG with Icedove - http://www.enigmail.net/

        iEYEARECAAYFAlNijrQACgkQbtUV+xsoLpo6pgCeJY28/oVCDAbe5l1biS/L1zXI
        Zc0An3vndd5kH17I3S7c3MDSaPuGbKyr
        =62wa
        -----END PGP SIGNATURE-----

         
  • alejandro1957
    alejandro1957
    2014-05-01

    okay.
    but I have seen the function _ltoa (unsigned long, char *, unsigned char) in the library stdlib.h
    I did not understand how to use it.

     
  • alejandro1957
    alejandro1957
    2014-05-01

    I wrote two lines to test this function

    include <pic16f877a.h>
    include <stdlib.h>
    include <stdio.h>
    include <Delay.h>
    
    code int __at 0x2007 CONFIG = _XT_OSC & _WDT_OFF & _PWRTE_ON & _BODEN_ON & _LVP_OFF & _CPD_OFF & _WRT_OFF & _DEBUG_ON & _CP_OFF;
    
    void Init_config()
         {
          TRISA=0b000000;
          TRISB=0b00001000;
          TRISC=0b00011000;
          TRISD=0b00000000;
          TRISE=0b000;
          PORTA=0b000000;
          PORTB=0b00000000;
          PORTC=0b00000000;
          PORTD=0b00000000;
          PORTE=0b000;
          INTCON=0b00000000;
          CCP1CON=0b00000000;
          CCP2CON=0b00000000;
          ADCON0=0b00000000;
          ADCON1=0b00000110;
         }
    
    void main()
         {
          char buffer[16];
          char *Linea;
          Init_config();
          Delay_ms(1000);
          while(1)
               {
                Linea=_ltoa(64000,buffer,10);
               }
         }
    

    and gives me this error:
    error 47: indirections to different types assignment
    where am I wrong?

     
    Last edit: Raphael Neider 2014-05-01
  • Raphael Neider
    Raphael Neider
    2014-05-01

    I'm sorry to inform you that the C standard library is basically not available for SDCC/pic14 targets. You will have to implement ltoa() or sprintf() yourself (or grab existing code and compile it along with your project).
    Regarding the error, the complete error message in my recreated test case is

    ltoa.c:9: error 47: indirections to different types assignment   
    from type 'void fixed'
      to type 'char generic* fixed'
    

    which even tells us that _ltoa does return void, which cannot be assigned to char *.
    Let me state again that the pic14 backends do not have a libc implementation available. stdio.h and stdlib.h (and _ltoa()) are taken from the default SDCC libc, which is not used/implemented for pic14. You need to provide the conversion routines in your own code. You can try to copy the code from SDCC's _ltoa() (and _ultoa()) implementations by downloading SDCC source archives and looking at device/lib/_ltoa.c.

    Raphael

     
  • alejandro1957
    alejandro1957
    2014-05-01

    ok, thanks