This blog post give a simple example of how to interact with PSoC6 step by step.
BOM: PSoC6 WiFi-BT Pioneer Kit.
First of all, I have installed the ModusToolbox 2.1 version by following the ModusToolbox Installation Guide and read through the ModusToolbox User Guide.
I then started to test out the example code in the ModusToolbox 2.1.
Clicking New Application at the bottom left corner.
Choosing the Board Support Package(BSP):
In my case, I chose the BSP for CY8CKIT-062-WIFI-BT and clicked Next>.
Choosing a Starter Application:
There are various of Starter Application to assist a beginner like me. To get familiarize with the ModusToolbox 2.1, I chose a Hello World starter application.
The application name can be changed in the Application Name column if wished. In my case, I will just leave it as it be and click the Next> button and then Finish button to generate the application.
When the application is created completely, a README.md file that explains how the application works will show up.
Scroll down to the Operation part and follow the instruction to get the application works.
This application requires us to have a terminal program. In my case, I used Tera Term which can be downloaded here: teraterm-4.105.exe
After downloading and launching Tera Term, in the serial port section, choose KitProg3 and click OK button.
From the navigating tab, click Setup and choose Serial Port... , a Tera Term: Serial port setup and connection tab will pop up.
Set the speed to 115200, which is the baud rate of the PSoC 6 WiFi-BT Pioneer Kit and click New setting button.
Back to the ModusToolbox 2.1, in the Quick Panel, scroll to the Launches tab and click <application name> Program (KitProg 3) button to program and run the application.
The Tera Term will print these lines once the building and running process complete.
Hello World testing on PSoC6
After testing the Hello_World application on PSoC6, it is good to look through the code to get familiarize with the functions which can be used to initialize the pin and peripherals of PSoC6.
In the Project Explorer, under Hello_World, there is a main.c file. Opening the main.c allows us to look through the code for the application.
Here are the few lines of code that I personally think that they are important so I marked them down for future usage.
cyhal_gpio_init(CYBSP_USER_LED, CYHAL_GPIO_DIR_OUTPUT, CYHAL_GPIO_DRIVE_STRONG, CYBSP_LED_STATE_OFF);
void timer_init(void) { cy_rslt_t result; const cyhal_timer_cfg_t led_blink_timer_cfg = { .compare_value = 0, /* Timer compare value, not used */ .period = LED_BLINK_TIMER_PERIOD, /* Defines the timer period */ .direction = CYHAL_TIMER_DIR_UP, /* Timer counts up */ .is_compare = false, /* Don't use compare mode */ .is_continuous = true, /* Run timer indefinitely */ .value = 0 /* Initial value of counter */ };
/* Configure timer period and operation mode such as count direction, duration */ cyhal_timer_configure(&led_blink_timer, &led_blink_timer_cfg); /* Set the frequency of timer's clock source */ cyhal_timer_set_frequency(&led_blink_timer, LED_BLINK_TIMER_CLOCK_HZ); /* Assign the ISR to execute on timer interrupt */ cyhal_timer_register_callback(&led_blink_timer, isr_timer, NULL); /* Set the event on which timer interrupt occurs and enable it */ cyhal_timer_enable_event(&led_blink_timer, CYHAL_TIMER_IRQ_TERMINAL_COUNT, 7, true); /* Start the timer with the configured settings */ cyhal_timer_start(&led_blink_timer);
static void isr_timer(void *callback_arg, cyhal_timer_event_t event) { (void) callback_arg; (void) event; /* Set the interrupt flag and process it from the main while(1) loop */ timer_interrupt_flag = true; }
The functions are used to initialize the timer.