Announcements
IMPORTANT: Cypress Developer Community is transitioning on October 20th. To learn more and be prepared for this change, check out our latest announcement.
cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

ShVy_264716
New Contributor II

I have a CY8CKIT-059 PSoC® 5LP Prototyping Kit With Onboard Programmer and Debugger. I have already done LED Blinking successfully. I need to Configure UART in it in such a way that I do not need to solder any wire in it and use its USB programmer connection. But it gets programmed through SWDIO and SWDCLK, so I do not know how to map UART to SWD/JTAG in it using Cypress Creator 4.3 that I am using. Kindly help me with this issue.

With Profound Regards

Vyas Shaunak Agastya

+91 98250 86749

0 Likes
1 Solution
MotooTanaka
Esteemed Contributor

Hi,

Previous sample might be a overkill.

I wrote a simpler sample without using interrupt for CY8CKIT-059.

(But for real applications using interrupt would be better)

schematic

002-schematic.JPG

pins

003-pins.JPG

main.c

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

#include "project.h"

#include "stdio.h"

#define STR_LEN 32

#define BS      '\b'

#define CR      '\r'

#define NL      '\n'

#define LED_ON  1u

#define LED_OFF 0u

int main(void)

{

    int     str_received = 0 ;

    uint8_t c ;

    char    str[STR_LEN+1] ; /* 1 for NULL */

    int     index = 0 ;

   

    CyGlobalIntEnable; /* Enable global interrupts. */

    LED_Write(LED_OFF) ;

   

    UART_Start() ;

    UART_PutString("\x1b[2J\x1b[;H") ; /* clear screen */

    UART_PutString("A Simple UART Test on CY8CKIT-059 ") ;   

    snprintf(str, STR_LEN, "(%s %s)\n\r", __DATE__, __TIME__) ;

    UART_PutString(str) ;

    UART_PutString("> ") ;

    for(;;)

    {

        if ((str_received == 0)&&(UART_GetRxBufferSize() > 0)) { /* received some lstters */

            c = UART_GetByte() ;

            switch(c) {

            case BS: /* backspace */

                if (index > 0) {

                    index-- ;

                    str[index] = 0 ;

                    UART_PutString("\b \b") ; /* BS, space, BS */

                }

                break ;

            case CR:

            case NL:

                str[index] = 0 ; /* terminate the string */

                index = 0 ;

                str_received = 1 ;

                UART_PutChar(c) ;

                break ;

            default:

                str[index] = c ;

                index++ ;

                if (index >= STR_LEN) { /* buffer overflow */

                    str[STR_LEN] = 0 ;

                    index = 0 ;

                    str_received = -1 ;

                }

                UART_PutChar(c) ;

                break ;

            }

        }

       

        if (str_received) { /* a string is received (or overflow) */

            if (strcmp(str, "on") == 0) {

                LED_Write(LED_ON) ;

            } else {

                LED_Write(LED_OFF) ;

            }

            UART_PutString("String Received: ") ;

            UART_PutString(str) ;

            UART_PutString("\n\r") ;

           

            str_received = 0 ;

            UART_PutString("> ") ;

        }

    }

}

/* [] END OF FILE */

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

Tera Term log

Note: Only when you type "on", LED lights

001-TeraTerm-log.JPG

moto

P.S. I found a bug in processing BS, and fixed it.

Please use/refer simple_uart_test_059_200910.cyprj.Archive02.zip

main.c was also updated.

View solution in original post

0 Likes
2 Replies
MotooTanaka
Esteemed Contributor

Hi,

If you are using CY8CKIT-059 without modification,

UART is already connected to its USB-Serial part of KitProg.

So you can use both UART and SWD without problem.

I posted following sample before, please play with it 😉

MCU Tester, a Swiss Army Knife for PSoC (CY8CKIT-059 version)

moto

P.S. Please use the one I attached last (at the bottom of the discussion)

0 Likes
MotooTanaka
Esteemed Contributor

Hi,

Previous sample might be a overkill.

I wrote a simpler sample without using interrupt for CY8CKIT-059.

(But for real applications using interrupt would be better)

schematic

002-schematic.JPG

pins

003-pins.JPG

main.c

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

#include "project.h"

#include "stdio.h"

#define STR_LEN 32

#define BS      '\b'

#define CR      '\r'

#define NL      '\n'

#define LED_ON  1u

#define LED_OFF 0u

int main(void)

{

    int     str_received = 0 ;

    uint8_t c ;

    char    str[STR_LEN+1] ; /* 1 for NULL */

    int     index = 0 ;

   

    CyGlobalIntEnable; /* Enable global interrupts. */

    LED_Write(LED_OFF) ;

   

    UART_Start() ;

    UART_PutString("\x1b[2J\x1b[;H") ; /* clear screen */

    UART_PutString("A Simple UART Test on CY8CKIT-059 ") ;   

    snprintf(str, STR_LEN, "(%s %s)\n\r", __DATE__, __TIME__) ;

    UART_PutString(str) ;

    UART_PutString("> ") ;

    for(;;)

    {

        if ((str_received == 0)&&(UART_GetRxBufferSize() > 0)) { /* received some lstters */

            c = UART_GetByte() ;

            switch(c) {

            case BS: /* backspace */

                if (index > 0) {

                    index-- ;

                    str[index] = 0 ;

                    UART_PutString("\b \b") ; /* BS, space, BS */

                }

                break ;

            case CR:

            case NL:

                str[index] = 0 ; /* terminate the string */

                index = 0 ;

                str_received = 1 ;

                UART_PutChar(c) ;

                break ;

            default:

                str[index] = c ;

                index++ ;

                if (index >= STR_LEN) { /* buffer overflow */

                    str[STR_LEN] = 0 ;

                    index = 0 ;

                    str_received = -1 ;

                }

                UART_PutChar(c) ;

                break ;

            }

        }

       

        if (str_received) { /* a string is received (or overflow) */

            if (strcmp(str, "on") == 0) {

                LED_Write(LED_ON) ;

            } else {

                LED_Write(LED_OFF) ;

            }

            UART_PutString("String Received: ") ;

            UART_PutString(str) ;

            UART_PutString("\n\r") ;

           

            str_received = 0 ;

            UART_PutString("> ") ;

        }

    }

}

/* [] END OF FILE */

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

Tera Term log

Note: Only when you type "on", LED lights

001-TeraTerm-log.JPG

moto

P.S. I found a bug in processing BS, and fixed it.

Please use/refer simple_uart_test_059_200910.cyprj.Archive02.zip

main.c was also updated.

View solution in original post

0 Likes