Announcements
IMPORTANT: Cypress Developer Community is transitioning on October 20th. To learn more and be prepared for this change, check out our latest announcement.
cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC Creator & Designer Software

Anonymous
Not applicable

Hello everyone;

                       I am writing smartcard using i2c communication in PSoC 3. when  debugging code i got the following error . such as syntax error near uint8. Actually uint8 is a valid data types in psoc  compiler.other error is ``buffer"  undefined identifier .but buffer is already defined.  why it show like this.  I searched internet about this error but i can't get answer.. Please help me .

main.c

#include "project.h"

#include "I2C.h"

uint8 a,zone;

int main(void)

{

for( zone=0;zone<5;zone++)

{

  uint8 set(uint8 address, uint8 *Data,uint8 Num);

}

CyGlobalIntEnable;

}

uint8 set(uint8 address, uint8 *Data, uint8 Num)

{

Num=3;

address=0xB0;

   

if(zone==0)

{

      uint8 buffer[]={03,00,00};

      Data=buffer;

        

}

   else if(zone==1)

   

    for(a=0;a<3;a++)

    {

        Data=0;

      

    }

    uint8 buffer[]={03,01,00};//syntax error near 'uint8'

    Data=buffer;

   

}

  else if(zone==2)

{

     for(a=0;a<3;a++)

    {

        Data=0;

       

    }

    uint8 buffer[]={03,02,00};//syntax error near 'uint8'

    Data=buffer;//undefined identifier

   

}

   

    else if (zone==3)

    {

        for(a=0;a<3;a++)

    {

       Data=0;

    }

    uint8 buffer[]={03,03,00};//syntax error near 'uint8'

    Data=buffer;//undefined identifier

   

   

   }

    else

    {

    }

        return 0;

   

uint8 I2C_Send(uint8 address,uint8 *Data,uint8 Num);//syntax error near 'uint8'

uint8 writezone(uint8 address,uint8 *Data,uint8 Num);

}

uint8 writezone(uint8 address ,uint8 *Data,uint8 Num)

{

address=0xB4;

        if(zone==0)

        {

            Num=8;

          

    for(a=0;a<3;a++)

    {

        Data=0;

    }

     uint8 buffer[]={00,00,05,00,07,03,04,03};

    Data=buffer;

        }

    

  else if(zone==1)

{

     Num=0;

    Num=7;

    for(a=0;a<8;a++)

    {

        Data=0;

    }

    uint8 buffer[]={00,00,04,00,07,03,05};

    Data=buffer;

}

    else if(zone==2)

    {

     Num=0;

     Num=6;

        for(a=0;a<7;a++)

    {

        Data=0;

    }

      uint8 buffer[]={00,00,03,00,65,73};

       Data=buffer;

    }

    else if(zone==3)

    {

        Num=0;

        Num=5;

         for(a=0;a<6;a++)

    {

        Data=0;

    }

     uint8 buffer[]={00,00,02,74,76};

    Data=buffer;

    }

  

        else

    {

    }

        return 0;

   

   

   

    uint8 I2C_Send(uint8 address,uint8 *Data,uint8 Num);

    uint8 Readzone(uint8 address,uint8 *Data,uint8 Num);

}

         

uint8 Readzone(uint8 address,uint8 *Data , uint8 Num)

{

address=0xB2;

    Num=3;

   

    if(zone==0)

    {

    

     for(a=0;a<8;a++)

    {

        Data=0;

    }

   

    uint8 buffer[]={00,00,05};

    Data=buffer;

    }

   

   

    else if(zone==1)

    {

     for(a=0;a<7;a++)

    {

        Data=0;

    }

     uint8 buffer[]={00,00,04};

    Data=buffer;

      } 

     else if(zone==2)

    {

     for(a=0;a<6;a++)

    {

        Data=0;

    }

     uint8 buffer[]={00,00,03};

    Data=buffer;

      } 

          

       else if(zone==3)

    {

     for(a=0;a<5;a++)

    {

        Data=0;

    }

     uint8 buffer[]={00,00,02};

    Data=buffer;

      }

        else

    {

    }

        return 0;

    uint8 I2C_Read(uint8 address,uint8 *Data, uint8 Num);

   

   

0 Likes
2 Replies
Roy_Liu
Moderator
Moderator

Should variables be defined and initialized at the beginning of a function?

Roy Liu
0 Likes
Bob_Marlowe
Expert II

It is always easier for us looking for issues when you post your complete project so that we all can have a look at all of your settings. To do so, use

Creator->File->Create Workspace Bundle (minimal)

and attach the resulting file.

Bob

0 Likes