4 Replies Latest reply on Jul 13, 2015 4:46 AM by user_14586677

    Pointer Function Error

    coderun

      Hi guys. 

         

      PSoc Designer amazes me. I can not do ordinary operations(in C)..

         

      When I run below code, it does not works.

         

      FuncCb cbfunc = 0;
      void main(void)
      {
          
          if (0 == cbfunc) {
              f = foo;
              f();
      }

         

       

         

      But When I run below code, it is working

         

      FuncCb cbfunc = 0;

         

      FuncCb x = 0;
      void main(void)
      {
          
          if (x == cbfunc) {
              f = foo;
              f();
      }

         

      I think it is cast problem. But it is not problem in ANSI C. Does PSoC support all ANSI C rules?

         

      Is there anyone with an idea?

        • 1. Re: Pointer Function Error
          user_1377889

          Can you please post the complete project example. We cannot see what runs and what not.

             

          PSoC4 and 5 are running GCC which is ANSI C. PSoC3 might be a bit different.

             

           

             

          Bob

          • 2. Re: Pointer Function Error
            coderun

            typedef void (*FuncCb)(void);

               

            void callbackFunc(void)
            {
                PRT0DR |= 0x01;
            }

               

            FuncCb pFunc = 0;  //it used to call related function
            FuncCb emptyPointer; // test pointer. it used instead of 0 (NULL)address
            void main(void)
            {
                
                if (0 == pFunc ) {   // if you use emptyPointer instead of "0", it is working. But now it not working.
                    pFunc  = callbackFunc;
                    pFunc ();
                }
                
                while (1)
                    ;
            }

            • 3. Re: Pointer Function Error
              user_1377889

              Coderun,

                 

              what makes you expect me to

                 
                    
              • Create a new project in PSoC Designer 5.???
              •     
              • Guessing the Chip you used
              •     
              • Guessing the stack settings you made.
              •     
              • Pasting your code and then starting to compile
              •    
                 

              when you could deliver an archive which I could open right out-of-the box.

                 

               

                 

              Bob

              • 4. Re: Pointer Function Error
                user_14586677

                Consider posting your project, makes life easier to troubleshoot.

                   

                 

                   

                “File”                                                           Designer

                   

                “Archive Project”

                   

                 

                   

                Regards, Dana.