char comparition on if Imagecraft

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

cross mob
Anonymous
Not applicable

Hi,

   

I'm developing some UART communication with PSoC 1 and I'm getting this error:

   

type error in argument 2 to `strstr'; found `pointer to __flash char' expected `pointer to char'

   

Code is as simple as this:

   

if (strstr(rx_buff,"OK") != NULL)
            {
               LED_On();
            }

   

Am I missing something? this "__flash" thing it's new to me on C.

   

also apears when I try to compare some char on an IF.

   

char test[3] = "OK"

   

if ( test == "OK") ---> this lines gives again __flash error.

   

Have been trying and reading texts but I don't get it, any documentation on __flash or an advice?

   

Thank you in advance.

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You are here on a von Neumann machine which has different instructions when accessing data in flash ("OK") and data in sram (rx_buff). For some library routines there were replacements which took that into account. They would be named cstrstr() or strcstr(), but I do not know whether they have been implemented for PSoC1.

   

A good tip for you is really: get a CY8CKIT-043 and switch to a modern ARM CPU.

   

 

   

Bob

View solution in original post

0 Likes
2 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You are here on a von Neumann machine which has different instructions when accessing data in flash ("OK") and data in sram (rx_buff). For some library routines there were replacements which took that into account. They would be named cstrstr() or strcstr(), but I do not know whether they have been implemented for PSoC1.

   

A good tip for you is really: get a CY8CKIT-043 and switch to a modern ARM CPU.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Thank you, Bob!! Yeah, I have been developing on PSoC 5LP (CY8CKIT-059) and when some partner asked me to develop on PSoC 1 it was a huge change, and yes, switching to a modern ARM CPU it's a great tip. Again, thank you for your answer and time. 

0 Likes