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

    Problem to store in memory PSOC



      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 ;       








      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



          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

            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 ?



            • 3. Re: Problem to store in memory PSOC

              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.