UART to output message - A simple program for beginners using Modus Toolbox2.1 with PSoC6(M4)

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Kenshow
Level 8
Level 8
Distributor - Marubun (Japan)
50 solutions authored 25 solutions authored 10 solutions authored

Hi all,

I am making some programs for beginners using Modus ToolBox 2.1. When migrating the development environment from PSoc Creator to Modus, I had a hard time creating a simple program. Especially, there are few simple samples using the Device Configuration tool.

Here, a simple program for the M4 core of PSoC 6 using the Device Configuration tool of Modus Toolbox2.1 is introduced here.

The environment is as follows.

ModusToolbox2.1

CY8CKIT-062-BLE

This time, it is a method to output a message on the terminal by using the UART function of SCB.

Select the CY8CKIT-062-BLE kit from the New Application tool in the Quick Panel and use it based on what was created in the empty PSoC 6 app.

About the pin setting, start the Device Configuration tool from the Quick Panel in the IDE of Modus Toolbox2.1, and set it according to the following procedure.

1.png

Go to “Peripheral” tab.

Check Serial Communication Block (SCB) 5, Name is "KIT_UART".

Personality chooses “UART = 1.0”.

Also set the parameters on the right. For communication settings, use the above settings (default) and set the following.

Clock:8bit Divider 1 clk

Rx:P5[0] digital_inout

Tx:P5[1] digital_inout

Now you can set Pin and Clock at the same time. Just in case, check the “Pin” and “Peropheral-Clocks” tabs.

The program is as follows. The message is output by the Cy_SCB_UART_PutString() function.

int main(void)

{

    cy_rslt_t result;

    cy_stc_scb_uart_context_t KIT_UART_context;

    /* Initialize the device and board peripherals */

    result = cybsp_init() ;

    if (result != CY_RSLT_SUCCESS)

    {

        CY_ASSERT(0);

    }

    /* Turn on the UART */

    Cy_SCB_UART_Init( KIT_UART_HW, &KIT_UART_config, &KIT_UART_context );

    Cy_SCB_UART_Enable( KIT_UART_HW );

    __enable_irq();

    Cy_SCB_UART_PutString(KIT_UART_HW, "Hello PSoC \n\r" );

    for (;;)

    {

    }

}

Since I used TeraTerm as a terminal, the setting is described below.

2.png

Note: “Port” is depending on the PC environment.

It's easy. First, why don't you get used to Modus toolbox from this program?

Thanks,

Kenshow

0 Likes
2 Replies
Takashi_M
Moderator
Moderator
Moderator
1000 replies posted 500 solutions authored 750 replies posted

Dear Kenshow-san,

Thank you very much for your sharing this CE.

Best regards.

0 Likes
Kenshow
Level 8
Level 8
Distributor - Marubun (Japan)
50 solutions authored 25 solutions authored 10 solutions authored

Hi,

I changed the order in which API functions are called and updated the program.

Thanks,

Kenshow

18-June-2020

0 Likes