1 2 Previous Next 15 Replies Latest reply on Jan 23, 2017 9:05 AM by userc_39170

    Use of Uart_PutArray()

      I'm a beginner using PSOC 3 to complete a project for my masters. I've been trying to use to the Uart_PutArray function to transmit an Array to the PC using Uart.


      here's some code I've used to simulate an application segment


      #include <project.h>
      #include <stdio.h>
      #include <stdlib.h>


      uint8 count[256];
      uint8 channel;
      int i,x,j;


      int main()
          CyGlobalIntEnable; /* Enable global interrupts. */


              UART_1_PutArray(const uint8 count[],uint8 256);




          void init()
      /* [] END OF FILE */

        • 1. Re: Use of Uart_PutArray()

          Welcome in the forum!


          ... and what does not work as you expect? Keep in mind that serial interface of a PC is at +-12V which might destroy your PSoC which has got a TTL level of 5V(as max), so you will need a level-shifter as MAX232. When you are using a CY8CKIT-030 there already is a level shifter on it, you just have to enable it and jumper Tx and Rx. Alternatively you an use an USBUART component, use the second USB-port of the board and using an emulated com-port on the PC side.


          Can you please 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.





          • 2. Re: Use of Uart_PutArray()

            Thanks Sir for the quick response. I'm trying to use the above code to simulate the array count data, and then to implement it into my project code to see if my project is capable of using the simulated array to transmit to the PC using the UART. The problem that I'm facing is that the TERA Term doesn't get any output from the PSOC 3. The Aim is to transfer the array data to The PC and Labview will be used to plot count vs count index.

            • 3. Re: Use of Uart_PutArray()

              I would suggest you to start with a simple "Hello world" program.


              Do not forget that in the world of embeddeds there usually is an infinite loop preventing main() to be exited.


              So you can check out if your wiring is correct.


              You transmit non-ascii data which your teraterm will show as garbage.





              • 4. Re: Use of Uart_PutArray()

                Theosel: I don't have a PSOC 3 board but this PSOC 5 program should help you in the UART area.  I tried your program on a PSOC 4 Pioneer board and it seemed to have an issue with the Void call.  This program sends ADC data from the PSOC 5 to the Putty terminal and has some control keys to output the data.  Like S for free run of the data and X stops the data dump.  Please read the PDF file with the program for more info. 

                1 of 1 people found this helpful
                • 5. Re: Use of Uart_PutArray()

                  Thank you for your valuable insights. I've worked with an DAC,ADC coupled together and their output is can be viewed on the Character LCD.. However the scope of my project is to use the PSOC 3 to store ADC output data in various bins and send it as a bulk ie the Array. Since I'm hard pressed on the Application data, I'm trying to simulate the input and output sections of my project.

                  • 6. Re: Use of Uart_PutArray()

                    I am working on a PSoC 3 design using CY8C3866AXI-040 chip to monitor voltage rails on the board and would like to format string with voltage reading and send to UART Console for display but encountered issue with sprintf(). I am using PSoC Creator 3.3.


                    With the code below, I'm expecting "Line 0", "Line 1",... "Line 7" to be shown on the UART Console but instead I got these "Line 0", "Line 256", "Line 512", Line 768", "Line 1024", "Line 1280", "Line 1536", "Line 1792". I don't really know what was wrong. Please help.


                    int main()
                        uint8 ii;
                        char msgbuf[128];


                        CyGlobalIntEnable; /* Enable global interrupts. */


                        UART_Start(); /* init and start uart */
                        CyDelay(10);  /* allow uart init time */
                        for (ii = 0; ii < 8; ii++) {
                            sprintf(msgbuf, "Line %d\r\n", ii);
                            UART_PutArray(msgbuf, strlen(msgbuf));
                            /* Place your application code here. */

                    • 7. Re: Use of Uart_PutArray()

                      Welcome in the forum!


                      %d format expects an int to display. So better use


                              sprintf(msgbuf, "Line %d\r\n", (int)ii);





                      • 8. Re: Use of Uart_PutArray()

                        Thank you Bob. This was it. Really appreciated your help!

                        • 9. Re: Use of Uart_PutArray()

                          Hi Everyone,


                          I am encounter sprintf issue with format %08X to print 32bit hex value. The formatted string displayed on UART port shows only upper 16bit value. Please help. My simple test code is as follow:


                          void my_test_func (void)




                              const uint8 msgbuf[128];       


                              uint32 expected_val = 0x874810B5; /* PEX8748 MFR & DEV ID */


                              sprintf(&msgbuf[0], "PEX8748 MFR&DEV ID expected 0x%08X\r\n", (uint32) expected_val);


                              UART_PutArray((const uint8 *)&msgbuf[0], strlen(msgbuf));




                          The output string shown on the uart console:


                          PEX8748 MFR&DEV ID expected 0x00008748

                          • 10. Re: Use of Uart_PutArray()

                            You probably need to use lX (small letter "L") to indicate that it is a long value. See C-manual excerpt.





                            • 11. Re: Use of Uart_PutArray()

                              Thanks Bob. That was it. Appreciate your help!

                              • 12. Re: Use of Uart_PutArray()

                                You are always welcome!


                                I have to admit that for getting answers for exactly these questions I have to look into the manual also. Cannot keep them in mind...





                                • 13. Re: Use of Uart_PutArray()

                                  Hello. I am new to the forum and I am working on a similar project using CY8C3866AXI-040. The aim is to acquire data from ADC, convert it and transmit it through UART. Please tell me,


                                  @theosel92_1467891, Were you able to run it successfully? I would be grateful if you could share your work.
                                  Could you share the link for labview? I made a software using visual studio but I am not satisfied with it. Here is the link: https://1drv.ms/u/s!AmTOHfqkfh3SvHtBHJ2YzOvrLyl0 
                                  what changes may be required for using the ADC in a 16 bit resolution?


                                  I have a schematic diagram of the kit I am using. While I could obtain data from ADC, I am unable to transmit it through UART. I say this because I could not see any result on TeraTerm.

                                  • 14. Re: Use of Uart_PutArray()
                                            Hello milinds, it's been a while since I worked with the psoc3.. Will definitely get back to you on my project work.. As far as I remember teraterm couldn't display the output of the ADC, something to the output being ASCII coded .. However preliminary results were observed on LabVIEW a LCD compatible with the Psoc3 kit - Selwyn   
                                    1 2 Previous Next