PSoC1 function pointer doesn't work with assembly functions?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
ReWa_1071226
Level 1
Level 1

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.

0 Likes
1 Solution
Roy_Liu
Moderator
Moderator
Moderator
5 comments on KBA First comment on KBA 10 questions asked

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

Roy Liu

View solution in original post

3 Replies
LinglingG_46
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 10 questions asked

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,

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?

0 Likes
Roy_Liu
Moderator
Moderator
Moderator
5 comments on KBA First comment on KBA 10 questions asked

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

Roy Liu