3 Replies Latest reply on Dec 12, 2018 9:23 PM by YuxianL_01

    PSoC1 function pointer doesn't work with assembly functions?

    ReWa_1071226

      Hi everyone,

       

      I tried to use function pointer recently in PSoC Designer with PSoC1 CY8C29466 and there's something I don't understand.

      First, I tried the following code and it works fine:

       

      #include <m8c.h>        // part specific constants and macros
      #include <stdio.h>
      #include "PSoCAPI.h"    // PSoC API definitions for all User Modules

       

      void func1(BYTE b1)
      {
          ACB00CR0 = b1; // I just picked this register to check if the function pointer is working in the debugger
      }

       

      void main(void)
      {
          M8C_EnableGInt ; // Uncomment this line to enable Global Interrupts

       

          void (*funcptr)(BYTE);

       

          funcptr = func1;
          funcptr(0xfe);
      }

       

      Then I add in a PGA module, and when I tried to used the funciton pointer to point to one of PGA's APIs, e.g. PGA_Start(), the compiler (or the linker) reports that "function "_PGA_Start" has wrong type for this function call (error)" and "can't generate code for this expression (error)".

       

      #include <m8c.h>        // part specific constants and macros
      #include <stdio.h>
      #include "PSoCAPI.h"    // PSoC API definitions for all User Modules

       

      void main(void)
      {
          M8C_EnableGInt ; // Uncomment this line to enable Global Interrupts

       

          void (*funcptr)(BYTE);

          

          funcptr = PGA_Start;     // I tried other APIs such as PGA_Stop, PGA_SetGain, and none works
          funcptr(PGA_HIGHPOWER); // The compiler (or the linker) will complain this line
      }

       

      The difference I can find is that the PGA's APIs are generated by the PSoC Desinger and are coded in assembly, but will this cause problems?

      Can anyone tell me what went wrong? Thank you.

        • 1. Re: PSoC1 function pointer doesn't work with assembly functions?
          LinglingG_46

          Hi,

           

          I try to change the codes to the below, then I have no compiler error.

           

          #include <m8c.h>        // part specific constants and macros
          #include <stdio.h>
          #include "PSoCAPI.h"    // PSoC API definitions for all User Modules

           

          void func1(BYTE b1)

          {

              ACB00CR0 = b1; // I just picked this register to check if the function pointer is working in the debugger

          }

           

          void (*funcptr)(BYTE);

              

          void main(void)
          {
              M8C_EnableGInt ; // Uncomment this line to enable Global Interrupts

           

           

              funcptr = PGA_Start;     // I tried other APIs such as PGA_Stop, PGA_SetGain, and none works
              funcptr(PGA_HIGHPOWER); // The compiler (or the linker) will complain this line
          }

           

          Thanks,

          1 of 1 people found this helpful
          • 2. Re: PSoC1 function pointer doesn't work with assembly functions?
            ReWa_1071226

            Hi,

             

            Thanks for the help.

             

            I forgot to say that I was using the Hi-Tech compiler.

             

            I tried the same change like you did and it works fine with the ImageCraft compiler but the Hi-Tech still complains and reports that "function "_PGA_Start" has wrong type for this function call (error)" and "can't generate code for this expression (error)". Is it the Hi-Tech compiler's problem?

            • 3. Re: PSoC1 function pointer doesn't work with assembly functions?
              YuxianL_01

              I think that's not a problem with Hi-Tech nor ImageCraft, nor PSoC Designer, it is nature of the different compliers. Hi-Tech is obsolete from supporting PSoC Designers.

              Cypress does not recommend PSoC1(1st generation of PSoC) for new designs, in case you need develop/debug PSoC1 design, recommend you use the latest PSoC Designer if possible.

              Migration from Hi-tech to ImageCraft:

              http://www.cypress.com/file/94511/download

              1 of 1 people found this helpful