5 Replies Latest reply on Mar 16, 2016 12:45 AM by gaurav.garg_1569466

    Read Data from external Microcontroller

    gaurav.garg_1569466

      I want to attach a BLE module like PSoC BLE to read the data from an external microcontroller via UART/SPI and store them in various characteristics of a BLE Service ( for eg. I want to read the data via UART rx (PSoC) and store it in temperature measurement characteristic of Health thermometer Service and then transfer this data using BLE HTP(Health thermometer Profile).) Any ideas / documents suggestions how to do it ? In what format the temp values should be sent from the external microcontroller and what should be in the firmware of PSoC to read it correctly ?

         

      Thanks in advance for any help :)

        • 1. Re: Read Data from external Microcontroller
          user_1377889

          Because the two microprocessors (the PSoC and the one delivering the data) might have different endianess it would be best to convert the yalues to ASCII, send them via serial interface and convert them back to digital (ints, floats) when needed. This allows to terminate the transmission of a data field with a newline which can be seen by the receiver.

             

           

             

          Bob

          • 2. Re: Read Data from external Microcontroller
            gaurav.garg_1569466

            Thank You very much for your  fast reply.  do u also know if we need to add some kind of address to identify which type of data it is ? . For eg if i am using the same UART port to send the data for two sensors such as weight measurement and temperature measurement. 

               

            How should it be sent from external microcontroller(lets say arduino from now) ?  How will my PSoC chip identify which value is it !

               

            Secondly, please correct me if i am wrong.In the PSOC creator 3.3 i think we need to configure UART in the design and initallize it accordingly so that it reads the data from arduino using UART rx (at PSOC).

            • 3. Re: Read Data from external Microcontroller
              user_78878863

              Short answer: whatever you want it to be.

                 

              Long answer: since you are writing the code for both systems, you are free to define the protocol for the PSoC BLE and the external MCU to communicate. Think about what data you need to transfer. Think about how you can synchronize both systems during startup and if anything goes wrong inbetween (e.g. a CS signal like SPI does).

              • 4. Re: Read Data from external Microcontroller
                user_1377889

                You may of course define a message as a struct in C-language which you send over th interface as

                   

                struct MyMessage {
                    char   SensorNumber;
                    char   SensorASCII[8];
                    char   XtraData;
                };

                   

                Using UART in PSoC:

                   
                      
                • Drop a UART onto your TopDesign
                •     
                • Double click on it and set properties (ie.Rx Buffer Size to 32)
                •     
                • Assign pins if not done automatically
                •     
                • Build
                •    
                   

                in main.c:

                   
                      
                • Call the UART's Start() function
                •     
                • Poll using _GetRxBufferSize() for number of characters received
                •     
                • retrieve characters using _GetChar() or GetByte(), see UART's datasheet
                •    
                   

                 

                   

                Bob

                1 of 1 people found this helpful
                • 5. Re: Read Data from external Microcontroller
                  gaurav.garg_1569466

                  Ok. Thank you very much for your detailed response! I will try this and will respond how it went .(y)