2 Replies Latest reply on Jan 9, 2018 2:58 AM by jaseelaka945_2746661

    optimised out

    jaseelaka945_2746661

      Iam using psoc creator 4.1 .I want to view the value of u_n8Zone by using breakpoint.But compiler show u_n8Zone is "optimised out"> .what is the reason for this.How do i view the value of u_n8Zone.

       

      Here is the code

      #include "project.h"

      #include "SmartCardI2C.h"

      #define true 1;

      #define false 0;

      int m;

      int ICCARD_STATUS_RECHARGE_SUCCESS;

      int ICCARD_STATUS_WRITE_FAIL;

      int ICCARD_STATUS_USED_CARD;

      int ICCARD_STATUS_READ_ERROR;

      int ICCARD_STATUS_CARD_NOT_PRESENT;

      int ICCARD_VALUE_SERVICE_USER;

      int ICCARD_STATUS_WRITE_SUCCES;

      int ICCARD_VALUE_FACTORY_USER;

      int ICCARD_STATUS_FACTORY_CARD;

      int ICCARD_STATUS_SERVICE_CARD;

      int ICCARD_VALUE_NORMAL_USER;

      int ICCARD_STATUS_NORMAL_CARD;

       

       

      int SMART_CARD_POWER_PIN;

      int GPIO_DIRECTION_OUT;

      int SMART_CARD_SENSE_PIN;

      int GPIO_DIRECTION_IN;

      int SMART_CARD_RESET_PIN;

      bool GetULongValueFromCard(u_int8_t u_n8ZoneNo,u_int8_t u_n8ZoneAddress,u_int32_t *ptr_u_n32Value);

      bool ReadCardUserZone(u_int8_t u_n8Zone,int nAddress,u_int8_t *ptr_u_n8Data,int nNoofBytes);

      int SendBytesToCard(int nNumber,u_int8_t *ptr_u_n8Data);

      u_int8_t GetRechargeValue(u_int32_t *ptr_u_n32RechargeValue);

      bool GetByteFromCard(u_int8_t u_n8ZoneNot ,u_int8_t u_n8ZoneAddress,u_int8_t *ptr_u_n8ByteAddress);

      bool WriteULongValuetoCard(u_int8_t u_n8Zone,u_int8_t u_n8ZoneAddress,u_int32_t u_n32ValueToLoad);

      void ReadBytesFromCard(int nNumber, u_int8_t *ptr_u_n8Data);

      bool GetULongValueFromCard(u_int8_t u_n8ZoneNo,u_int8_t u_n8ZoneAddress,u_int32_t *ptr_u_n32Value);

      int WriteCardUserZone(u_int8_t u_n8Zone,int nAddress,u_int8_t *ptr_u_n8Data,int nNoofBytes);

       

       

      int InitSmartCard();

      void  resetGetPinStatus();

      bool  GetCardPresentStatus();

       

       

       

       

      int main(void)

       

       

      {

      u_int32_t *ptr_u_n32Value;

        

         CyGlobalIntEnable;

        

      InitSmartCard();

       

       

      if(1==GetCardPresentStatus())

      {

          GetULongValueFromCard(10,1, ptr_u_n32Value);

      }

       

       

      return 0;

       

       

      }

       

       

       

       

      //SmartCard()

      //{

          //GPIO Sense()

              //GPIO Sense;

              //GPIO Power;

      //}

       

       

      int InitSmartCard()

      {

      int nI;

          InitializeI2C();

         

           cardrst_Write(1);

        

         

          //resetSetPinStatus();

          /*if(I2C_FAIL == InitializeI2C())

          {

              return SMART_CARD_FAIL;

          }

          if(GPIO_FAIL == SetPinDirection(GPIO_DIRECTION_OUT,SMART_CARD_POWER_PIN))

          {

              return SMART_CARD_FAIL;

          }

       

       

          return SMART_CARD_PASS;*/

          //WriteByteToCard(10,0,ICCARD_VALUE_FACTORY_USER);

         

          

             

              nI=WriteULongValuetoCard(10,1,100); 

          //SetcardasServiceCard();  

        return 0; 

       

         

      }

       

       

      u_int8_t GetRechargeValue(u_int32_t *ptr_u_n32RechargeValue)

      {

          bool bStat;

          if(1==GetCardPresentStatus())

          {

              bStat = GetULongValueFromCard(10,1,ptr_u_n32RechargeValue);

              if(1 == bStat)

              {

                  if((*ptr_u_n32RechargeValue)!=0)

                  {

                      if(1 == WriteULongValuetoCard(10,1,0))

                      {

                          return ICCARD_STATUS_RECHARGE_SUCCESS;

                      }

                      else

                      {

                          return ICCARD_STATUS_WRITE_FAIL;

                      }

                  }

                  else

                  {

                      return ICCARD_STATUS_USED_CARD;

                  }

              }

              else

              {

                  return ICCARD_STATUS_READ_ERROR;

              }

          }

          else

          {

              return ICCARD_STATUS_CARD_NOT_PRESENT;

          }

      }

       

       

      bool GetULongValueFromCard(u_int8_t u_n8ZoneNo,u_int8_t u_n8ZoneAddress,u_int32_t *ptr_u_n32Value)

      {

      if(1==ReadCardUserZone(u_n8ZoneNo,u_n8ZoneAddress,(u_int8_t*)(ptr_u_n32Value),4))

          {

              return true;

          }

          return false;

       

       

      }

      bool WriteULongValuetoCard(u_int8_t u_n8Zone,u_int8_t u_n8ZoneAddress,u_int32_t u_n32ValueToLoad)

      {

          return WriteCardUserZone(u_n8Zone,u_n8ZoneAddress,(u_int8_t*)(&u_n32ValueToLoad),4);

      }

       

       

      bool GetByteFromCard(u_int8_t u_n8ZoneNo,u_int8_t u_n8ZoneAddress,u_int8_t *ptr_u_n8ByteAddress)

      {

          return ReadCardUserZone(u_n8ZoneNo,u_n8ZoneAddress,ptr_u_n8ByteAddress,1);

      }

      bool WriteByteToCard(u_int8_t u_n8ZoneNo,u_int8_t u_n8ZoneAddress,u_int8_t u_n8Value)

      {

          return WriteCardUserZone(u_n8ZoneNo,u_n8ZoneAddress,&u_n8Value,1);

      }

      u_int8_t SetCardAsServiceCard()

      {

       

       

          if(1==GetCardPresentStatus())

          {

              //if(true == GetByteFromCard(10,0,&u_n8CardType))

              if(1 == WriteByteToCard(10,0,ICCARD_VALUE_SERVICE_USER))

              {

                  return 1;//ICCARD_STATUS_WRITE_SUCCES;

              }

              else

              {

                  return 2;// ICCARD_STATUS_WRITE_FAIL;

              }

          }

          else

          {

              return 3;// ICCARD_STATUS_CARD_NOT_PRESENT;

          }

      }

       

       

      u_int8_t CheckCardType()

      {

          u_int8_t u_n8CardType;

          if(1==GetCardPresentStatus())

          {

              if(1 == GetByteFromCard(10,0,&u_n8CardType))

              {

                  if(u_n8CardType == ICCARD_VALUE_FACTORY_USER)

                  {

                      return ICCARD_STATUS_FACTORY_CARD;

                  }

                  else if(u_n8CardType == ICCARD_VALUE_SERVICE_USER)

                  {

                      return ICCARD_STATUS_SERVICE_CARD;

                  }

                  else if(u_n8CardType == ICCARD_VALUE_NORMAL_USER)

                  {

                      return ICCARD_STATUS_NORMAL_CARD;

                  }

                  else

                  {

                      return ICCARD_STATUS_READ_ERROR;

                  }

              }

              else

              {

                  return ICCARD_STATUS_READ_ERROR;

              }

          }

          else

          {

              return ICCARD_STATUS_CARD_NOT_PRESENT;

          }

      }

       

       

      bool ReadCardUserZone(u_int8_t u_n8Zone,int nAddress,u_int8_t *ptr_u_n8Data,int nNoofBytes)

      {

          u_int8_t u_n8SendData[20];

          int nI=0;

       

       

          cardpower_Write(1);// SMART_CARD_POWER_ENABLE

       

       

       

          CyDelay(200);

       

       

          u_n8SendData[nI++] = 0xB4;

          u_n8SendData[nI++] = 0x03;

          //User Zone 0- read 8 bytes from here initially.

          u_n8SendData[nI++] = u_n8Zone;

          u_n8SendData[nI] = 0;

          nI = SendBytesToCard(4,u_n8SendData);

         i2cstop();

       

       

       

       

          if(nI ==1)

          {

              //read user config 0

       

       

              nI = 0;

       

       

              //Read Config Zone

              u_n8SendData[nI++] = 0xB2;

              u_n8SendData[nI++] = 0x00;

              //User Zone 0-

              u_n8SendData[nI++] = nAddress;

              u_n8SendData[nI] = nNoofBytes;

       

       

              nI = SendBytesToCard(4,u_n8SendData);

              if(nI == 1)////(nI==SMART_CARD_PASS )

                  ReadBytesFromCard(nNoofBytes,ptr_u_n8Data);

          }

       

       

          cardpower_Write(0);//SMART_CARD_POWER_DISABLE

       

       

          return 1;

       

       

      }

       

       

       

       

       

       

       

       

       

       

      int WriteCardUserZone(u_int8_t u_n8Zone,int nAddress,u_int8_t *ptr_u_n8Data,int nNoofBytes)

      {

          u_int8_t u_n8Senddata[200];

          int nI=0,nJ;

          cardpower_Write(0);//SMART_CARD_POWER_ENABLE

         CyDelay(200);

          //i = 0;

       

       

          //setting user zone

          u_n8Senddata[nI++] = 0xB4;

          u_n8Senddata[nI++] = 0x03;

          //User Zone 0- read 8 bytes from here initially.

          u_n8Senddata[nI++] = u_n8Zone;

          u_n8Senddata[nI] = 0;

           nI= SendBytesToCard(4,u_n8Senddata);

          i2cstop();

       

       

       

       

          if(nI ==1)//(nI==SMART_CARD_PASS )

          {

              //Write user zone

       

       

              nI = 0;

       

       

              //Write User zone

              u_n8Senddata[nI++] = 0xB0;

              u_n8Senddata[nI++] = 0x00;

              //User Zone 0- read 8 bytes from here initially.

              u_n8Senddata[nI++] = nAddress;

              u_n8Senddata[nI++] = nNoofBytes;

              for(nJ = 0;nJ < nNoofBytes;nJ++)

                  u_n8Senddata[nI++] = ptr_u_n8Data[nJ];

       

       

              nI = SendBytesToCard(nNoofBytes+4,u_n8Senddata);

              i2cstop();

          }

          //power down

          CyDelay(200);

          cardpower_Write(1);//SMART_CARD_POWER_DISABLE

       

       

          return 1;

       

       

      }

       

       

       

       

       

       

       

       

      void ReadBytesFromCard(int nNumber, u_int8_t *ptr_u_n8Data)

      {

          int nI=0;

          while(nNumber--)

          {

              ptr_u_n8Data[nI]=i2cgetbyte();

              nI++;

       

       

              if(nNumber > 0)

              {

                  i2csendack();

              }

          }

          i2cstop();

       

       

      }

       

       

      int SendBytesToCard(int nNumber,u_int8_t *ptr_u_n8Data)

      {

          int nI=0;

          int nRetry = 0;

           int var;

          i2cstart();

          while(nNumber--)

          {

             var =i2csendbyte(ptr_u_n8Data[nI]);

              if(!i2cgetack())

              {

                  i2cstart();

                  nNumber++;

                  nRetry++;

                  if(nRetry > 5)

                  return 0;

              }

              else

                 nI++;

                

          }

          

         return 1;  // SMART_CARD_PASS

       

       

      }

       

       

       

       

       

       

       

       

      void  resetGetPinStatus()

      {

      cardrst_Read();

      }

       

      bool GetCardPresentStatus()

      {

          if(0 == cardsense_Read())

          {

              return true;

          }

          else

          {

              return false;

          }

      }

       

        please help me to slove this problem.