3 Replies Latest reply on Jun 9, 2016 7:29 AM by user_1377889

    Problem to store in memory PSOC

    jesus.sola9_1581581

      Hello!!!

         


      I have a problem to store a data in memory PSoC . My code is as follows:

         

      uint8 datos [1 ]

         

      .......

         

      datos [ 0] = WriteRequestedParameter- > handleValPair.value.val [ 0];

         

      // Call the function to save

         

      Save_memory ( & datos [ 0] , sizeof (datos), CYBLE_BMP180_PRESSURE_CHAR_HANDLE ) ;

         

      //Function Save

         

      void Save_memory ( uint8 * Data, len uint8 , uint16 attrHandle )

         

      {             

         

       CYBLE_GATT_HANDLE_VALUE_PAIR_T datos_a_escribir ;          

         

      datos_a_escribir.attrHandle = attrHandle ;     

         

      datos_a_escribir.value.val = Data ;     

         

      datos_a_escribir.value.len = len ;       

         

       CyBle_GattsWriteAttributeValue(&datos_a_escribir,0,&cyBle_connHandle,CYBLE_GATT_DB_LOCALLY_INITIATED);

         

      }

         

       

         


      If such datos [ 0] contains 48 , I stored in memory 30 and not know why.

         

      - & Are wrong?

         

      - Where I have to put them?

         

      - datos [ ] array has to be a mandatory or may be only uint8 datos ;?
       

        • 1. Re: Problem to store in memory PSOC
          Madhu Lakshmipathy

          Hi,

             

          If I understood correctly, you stored 48, but you see 30 on memory. Please correct me if I understood wrongly.

             

          If so, 30 is hexadecimal value of 48. 0x30 = 48. Please check if there is any confusion caused because of this convention

          • 2. Re: Problem to store in memory PSOC
            jesus.sola9_1581581

            Hellow Madhu, you have understood correctly , send 48 to be stored and keep me in place 30 , always stores 18 numbers less than the original number. This means that stores the number in hexadecimal ? The code would be right then or can store the decimal value directly ?

               

            Thanks!!!

            • 3. Re: Problem to store in memory PSOC
              user_1377889

              Looks like the riddle Why is Halloween exactly the same as Christmas? (Answer: 31Oct = 25Dec)

                 

              The computer does not store data in hex or in decimal, both are only a way to represent the stored data or us humans, so that we are able to distinguish different information. You just have to check for yourself

                 
                    
              • in which format your number 48 was represented? a decimal?
              •     
              • in which format did you read back the result, was it in hexadecimal?
              •    
                 

              So with Madhu's presumption that 0x30 is equal to 48Dec (or equal to '0' in ASCII) your program is running correctly.

                 

               

                 

              Bob