cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC™ Creator & Designer

Anonymous
Not applicable

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?

0 Likes
4 Replies
Bob_Marlowe
Expert II

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

0 Likes
Anonymous
Not applicable

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)
        ;
}

0 Likes
Bob_Marlowe
Expert II

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

0 Likes
ETRO_SSN583
Esteemed Contributor

Consider posting your project, makes life easier to troubleshoot.

   

 

   

“File”                                                           Designer

   

“Archive Project”

   

 

   

Regards, Dana. 

0 Likes