Hello! This is the first part of my project blog for this AtTheCore design challenge. What interested me in applying for this challenge is the extensive capability of PSoC6 controllers and devkit with fancy capsense, oboard sensors, and the theme of using dual-core which I thought would be a nice thing to explore and build on as I hadn't got hands on into this anytime.
I am a final year undergrad majoring in Electrical Engineering with deep interests in embedded software and power electronics stuff. I currently work on batteries and management systems for them and have experience designing boards, writing up some code, and developing model-based designs + algorithms.
Table of Contents
Challenge goal
Through this challenge, I am looking to explore the dual-core capabilities of the controller using inter-process communication(IPC) and features of capsense utilizing PWM, ADC to do motor control. Initially, I had thought to use the PSoC creator studio and configure the blocks to set up different functionalities taking instances from one of my previous projects here at element14 DigitalFever: Stepper motor control with PSoC4. But the chip in CY8CKIT-062S4 doesn't have support on that software and also recommended tool is ModusToolbox for this challenge. So I got started with it and no wonder, it's an amazing platform providing flexibility in the configuration of peripherals, IOs, and classical eclipse-based coding environment. In one of the earlier roadtests, I had worked on a motor driver board IFX007T Motor Control Shield and will be utilizing it here for this application. I am planning to go with vertical implementation and to start off with:
Tool installation and getting started
The process of getting started with the kit was super easy and it also came with out of the box example showing CapSense and UART implementations. The development tool ModusToolbox installation is also straight forward (just that now I have yet one more new vendor-specific IDEs in the system)

| {gallery}My Gallery |
|---|
|
|
|
|
Example app - IPC semaphore, Capsense and ALS - M0, M4 projects
Next, I tapped into the example projects to understand how they're structured and shared. Apparently, any project involves Board Support Package(BSP) over which several libraries can be included based on user requirements with some being default and the super intuitive Library Manager in the Quick Panel window allows this.


The libraries added here are shared between projects by the ModusToolbox and a separate workspace folder called 'mtb_shared' is created. In case of dual-core applications, I saw that this shared inclusion is having some conflict with intellisense and always shows up a warning in header file inclusions and errors in using variables from the shared library which is said to be included properly with no warnings at the build, but the intellisense still keeps highlighting. Let me know if anyone else is seeing the same or has a solution.
Doing IPC with pushbutton, LED, and sensor data
Strating off with, I tried inter-process communication using semaphore. misaz 's roadtest post was a good reference there and I tried out what Jan Cumps mentioned about disabling the semaphore and seeing the chaos happen.

Next, I used the onboard ALS and Temperature sensors to get the data printed through UART with IPC on with the same game, but additional computations over CM4+ to acquire sensor data and stream out. This involved calling the UART print function inside the main for loop of CM4 side after enabling the semaphore and same remains on the CM0+ side. Checking if the button is pressed -> Enabling the semaphore -> Turning user LED ON -> UART Print -> Disabling the semaphore.
Code
CM4 side
if (cyhal_gpio_read(CYBSP_USER_BTN) == CYBSP_BTN_PRESSED)
{
#if ENABLE_SEMA
/* Attempt to lock the semaphore */
if (Cy_IPC_Sema_Set(SEMA_NUM, false) == CY_IPC_SEMA_SUCCESS)
#endif
{
/* Print a message to the console and turn Orange LED ON*/
cyhal_gpio_write(CYBSP_USER_LED2, CYBSP_LED_STATE_ON);
printf("Message sent from CM4\r\n"); /*UART transmit message*/
/*Also send sensor data*/
/* Wait till printf completes the UART transfer */
while(cyhal_uart_is_tx_active(&cy_retarget_io_uart_obj) == true);
/* Print the temperature and the ambient light value*/
printf("Temperature: %2.1lfC Ambient Light: %d%%\r\n", temperature, light_intensity);
printf("\n");
cyhal_system_delay_ms(1000);
cyhal_gpio_write(CYBSP_USER_LED2, CYBSP_LED_STATE_OFF);
#if ENABLE_SEMA
while (CY_IPC_SEMA_SUCCESS != Cy_IPC_Sema_Clear(SEMA_NUM, false));
#endif
}
}
CM0+ side
for (;;)
{
/* Check if the button is pressed */
if (Cy_GPIO_Read(CYBSP_SW2_PORT, CYBSP_SW2_PIN) == 0)
{
#if ENABLE_SEMA
if (Cy_IPC_Sema_Set(SEMA_NUM, false) == CY_IPC_SEMA_SUCCESS)
#endif
{
/* Print a message to the console and turn Red LED ON */
cyhal_gpio_write(CYBSP_USER_LED, CYBSP_LED_STATE_ON);
Cy_SCB_UART_PutString(CYBSP_UART_HW, "Message sent from CM0+\r\n"); /*UART transmit message*/
cyhal_system_delay_ms(1000);
cyhal_gpio_write(CYBSP_USER_LED, CYBSP_LED_STATE_OFF);
#if ENABLE_SEMA
while (CY_IPC_SEMA_SUCCESS != Cy_IPC_Sema_Clear(SEMA_NUM, false));
#endif
}
}
}

Further, I am working on the usage of CapSense and PWM control for motor control with IFX007T arduino shield and in the next blog, we'll explore how these can be put together and also how sensor data can be used to make a little more sense. Here I am enjoying the making challenge and thanks for reading through. Also, let me know what you think :)
References
| CY8CKIT-062S4 BSP |
| PSoC 6 Peripheral Driver Library: PDL API Reference (infineon.github.io) |
| ModusToolbox |
| CY8CKIT-062S4 - Infineon Technologies |
Also Read:
AtTheCore: Blog #2 - Interfacing LED Bar with ALS
Top Comments