2 Replies Latest reply on Oct 1, 2020 7:29 PM by MoTa_728816

    CY8CKIT-149 Prototyping Kit - How to Read Serial Data?

    JoJo_4453281

      Using the CY8CKIT-149 PSoC® 4100S Plus Prototyping Kit, what view the touchpad serial data in a terminal emulator? Reading serial data is a very important design consideration in my application.

        • 1. Re: CY8CKIT-149 Prototyping Kit - How to Read Serial Data?
          RakshithM_16

          Hi JoJo_4453281,

           

          You can use UART block to read and write serial data. You can refer to this code example CE224406 - PSoC 4 UART which prints data on the serial terminal application. You can refer to UART Component datasheet for more information regarding UART block.

          Please let me know if you have any further queries.

           

          Thanks and Regards,

          Rakshith M B

          • 2. Re: CY8CKIT-149 Prototyping Kit - How to Read Serial Data?
            MoTa_728816

            Hi,

             

            I made a simple sample using both UART and CapSense Tuner.

             

            You can enable/disable uart schematic or ezi2c schematic.

             

            If you disable both uart schematic and ezi2c schematic,

            the project just works as CapSense -> LED sample

             

            If you enable uart schematic, button state will be written to the serial output

             

            Tera Term Log

            001-TeraTerm-log.JPG

             

            If you disable uart schematic, and ezi2c schamtic is enabled.

            005-uart_disabled.JPG

            You can use CapSense Tuner.

            To use CapSense Tuner please note

            (1) Build and Write the Project into CY8CKIT-149

            (2) Make sure no serial terminal program is connected

            (3) Program is working (i.e. If you touch the button(4.5), the LED12 lights)

            (4) Then from the schematic of capsense

                 Right Click the CapSense component and select "Launch Tuner"

            006-lunch_tuner.JPG

            (5) When Sense Tuner Started, select "Connect" button

            007-connect.JPG

            (6) When Connected, Select "Start" button

            Note: I always forget this...

            008-Start.JPG

            (7) Then when you touch the CapSense Button, the level is graphically displayed

            WS000035.JPG

            when I touch the button

            WS000036.JPG

             

            Schematic

            Note: I created 3 pages

            1. capsense page

            002-sch_capsense.JPG

            2. uart page

            003-sch_uart.JPG

            3. ezi2c page

            004-sch_ezi2c.JPG

            Pins

            WS000000.JPG

             

            main.c

            ==================

            #include "project.h"

            #include "stdbool.h"

            #include "stdio.h"

             

            #if !uart__DISABLED

            #define USE_UART

            #define METHOD USE_UART

            #define STR_LEN 32

            char str[STR_LEN+1] ;

            void print(char *str)

            {

                UART_UartPutString(str) ;

            }

            void cls(void)

            {

                print("\033c") ; /* reset */

                CyDelay(20) ;

                print("\033[2J") ; /* clear screen */

                CyDelay(20) ;   

            }

            void splash(char *prog_name)

            {

                cls() ;

                if (prog_name && *prog_name) {

                    print(prog_name) ;

                }

                print(" (") ;

                print(__DATE__) ;

                print(" ") ;

                print(__TIME__) ;

                print(")\n") ;

            }

            #endif /* !uart__DISABLED */

             

             

            #if !ezi2c__DISABLED

            #ifndef USE_UART

            #define USE_TUNER

            #endif /* ifndef USE_UART */

            #endif /* !ez_i2c__DISABLED */

             

             

            #define LED_ON (0u)

            #define LED_OFF (1u)

             

             

            void init_hardware(void)

            {

                CyGlobalIntEnable; /* Enable global interrupts. */  

            #ifdef USE_UART

                    UART_Start() ;

                    splash("CY8CKIT-149 CapSense Test") ;

            #endif

            #ifdef USE_TUNER

                    EZI2C_Start() ;

                   

                    EZI2C_EzI2CSetBuffer1(sizeof(CapSense_dsRam),

                        sizeof(CapSense_dsRam),

                        (uint8 *)&CapSense_dsRam

                        );       

            #endif

            }

             

             

            int main(void)

            {

                bool buttonState = false;

               

                init_hardware() ;

               

                CapSense_Start() ;

                CapSense_ScanAllWidgets() ;

                for(;;)

                {

                    if (CapSense_NOT_BUSY == CapSense_IsBusy()) {

                        CapSense_ProcessAllWidgets() ;

                        buttonState  = CapSense_IsSensorActive(

                            CapSense_BUTTON0_WDGT_ID,

                            CapSense_BUTTON0_SNS0_ID

                            );

                       

            #ifdef USE_UART

                            snprintf(str, STR_LEN, "%d\n\r", buttonState) ;

                            print(str) ;

                            CyDelay(10) ;

            #endif

            #ifdef USE_TUNER

                            CapSense_RunTuner() ;

            #endif

                       

                        if (buttonState) {

                            LED12_Write(LED_ON) ;

                        } else {

                            LED12_Write(LED_OFF) ;

                        }

                       

                        CapSense_ScanAllWidgets() ;

                    }

                   

                    CyDelay(20) ;

                }

            }

            ==================

             

            moto