element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
At The Core Design Challenge
  • Challenges & Projects
  • Design Challenges
  • At The Core Design Challenge
  • More
  • Cancel
At The Core Design Challenge
Blog AtTheCore: Blog #5 - Bringing altogether, Multi-Core deployment and Application
  • Blog
  • Forum
  • Documents
  • Leaderboard
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join At The Core Design Challenge to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: navadeepganeshu
  • Date Created: 4 May 2023 10:14 PM Date Created
  • Views 826 views
  • Likes 4 likes
  • Comments 2 comments
  • inter-processor communication
  • PSoC 62S4 pioneer kit
  • dual-core
  • More At The Core Design Challenge
Related
Recommended

AtTheCore: Blog #5 - Bringing altogether, Multi-Core deployment and Application

navadeepganeshu
navadeepganeshu
4 May 2023
AtTheCore: Blog #5 - Bringing altogether, Multi-Core deployment and Application

Table of Contents

  • Introduction
  • Linking CM0+ and CM4 tasks
  • Testing both the Cores Simultaneously
  • IPC piping and exchanging messages for motor control
    • CM0+ side
    • CM4 side
  • Comparing % Memory Usage
    • CM4
    • CM0+
  • Code
  • Future Work
  • References
  • Also Read

Introduction

In this blog, we'll see how the integration of functionalities of Cortex M0 and Cortex M4 core and done by bringing in together the bits and pieces that I've demonstrated in the previous blogs. Starting off with this project majorly includes 4 functionalities, one being the Capsense touch and slider, ambient light sensor and temperature sensors, the LED bar indication based on the sensor data and the inter-process communication pipe. Also, the serial UART message transmission based on core activity is included in this.

As per the agenda of this At The Core Design Challenge, I've attempted to use both the cores and tried to use up to their limits, with user control utilizing CapSense, Motor control using multichannel PWM signal, all done inside Cortex M0 core. The next Cortex M4 4 interlinks with Cortex M0+ and they work interchangeably using lock/unlocking of semaphore and communicate through the IPC pipeline. Running on Cortex M4 is the LED bar indication based on the sensor data acquired. This also does the motor control signal transmission based on the ambient light sensor data.

The application which I am thinking of here is the automated curtain control. Data acquired from the light sensor - if it is greater than a certain threshold that is of the light coming from the window or within the room, then the Cortex M4 core will sense that particular limit and send the motor control initiation command to Cortex M0+ through IPC pipeline. Cortex M0 realising this data will activate the motor control and enable the user to use the Capsense utilities for doing this process. So let's look deeper into the builds and the whole firmware flow.

Linking CM0+ and CM4 tasks

Two are separate system cores running at different speeds. The tasks are tested individually for each core and one of the smart methods used in one of the example applications is the usage of semaphores to lock/unlock the task accordingly and sequentially run the tasks without collisions. We know what happens when a task is overridden or breaks in the process of execution. Using this locking method, the code is built on and it is clearly visualized in the dual-core application debug more which is quite a lot interesting and I spent quite some time clicking through and getting to know the flow. Here's the flowchart for this application having multi-peripherals coming to action.image

Starting with CM0+, the control is given to CM4 which does one set of initial processes and acts back enabling CM0+ again. The processes all after this run seemingly in parallel - really? No! but quite fluently handling the lock/unlock processes. The pushbutton is optionally kept for critical tasks which are locked/unlocked by semaphores to which the access is through a pushbutton press.

image

image
Testing both the Cores Simultaneously

image

image

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

IPC piping and exchanging messages for motor control

Uptil here, the cores ran their tasks and the usage of semaphore is seen to schedule tasks and run in sequence. Now, the challenge I came across is to transmit the data acquired from the light sensor to the motor control. These two tasks are in separate cores and I thought of having extern variable? Or would a variable be common for cores in dual-core application? No! And here comes the PIC pipe for the save. In the IPC driver layer, certain APIs are exposed and a pair of them is Cy_IPC_Drv_SendMsgWord() and Cy_IPC_Drv_SendMsgWord(). It assumes that the function is locked and thus does the IPC - so the user have to take care of lock/unlock before and after this process. However, in the earlier implementation, there is a semaphore lock and so these functions are also called in the same with some error handling:

CM0+ side

uint32_t myMsg; /* reception message variable */


/*MOTOR control state receive*/
IPC_STRUCT_Type * myIpc = Cy_IPC_Drv_GetIpcBaseAddress(MY_IPC_CHAN_INDEX); /* Get IPC base register address */
if ((CY_IPC_DRV_SUCCESS == Cy_IPC_Drv_ReadMsgWord(myIpc, &myMsg)) && (myMsg ==0x01))
{
    /* Now myMsg contains the received message word */
    /* The IPC data is received and processed.
     * Free up the channel for the next transaction.
     */
    	/*Allow MOTOR1 control ON*/
	    cyhal_gpio_write(CYBSP_A8, HIGH);
	    cyhal_gpio_write(CYBSP_A9, HIGH);

    Cy_IPC_Drv_ReleaseNotify(myIpc, MY_IPC_INTR_MASK);
}
else
{
    /* Insert error handling */
    Cy_SCB_UART_PutString(CYBSP_UART_HW, "Failed to receive MOTOR signal in IPC pipe\r\n");
    
    /*Inhibit motor action*/
    cyhal_gpio_write(CYBSP_A8, LOW);
    cyhal_gpio_write(CYBSP_A9, LOW);
    cyhal_system_delay_ms(500);
}

CM4 side

uint32_t myMsg = 0x00;

/*Motor ON full speed if ALS > 60% using IPC pipe*/
if(light_intensity >= ALS_THRESH_LEVEL6)
{
	IPC_STRUCT_Type * myIpc = Cy_IPC_Drv_GetIpcBaseAddress(MY_IPC_CHAN_INDEX); /* Get IPC base register address */
	myMsg = 0x1;        /* MOTOR control ON message */
	if (CY_IPC_DRV_SUCCESS != Cy_IPC_Drv_SendMsgWord(myIpc, MY_IPC_INTR_MASK, myMsg))
	{
		/* Insert error handling */
		printf("Failed to send MOTOR control ON signal in IPC pipe\r\n");
        cyhal_system_delay_ms(500);
	}
}

So in the below serial view, initially the MOTOR control ON message is not received and then whenever the light intensity is above 60% as set in the threshold, 0x01 message is sent in the pipe that is received on CM0+ side and allows the user to have button and PWM control of the motor. The idea with this is to pull the window curtain close when the light intensity is going too high by motorising it.

image

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image


Comparing % Memory Usage

Ok, time to see how much memory this application has utilized in each core and is it close to its full potential?

CM4

Calculating memory consumption: CY8C6244LQI-S4D92 GCC_ARM

----------------------------------------------------
| Section Name | Address | Size |
----------------------------------------------------
| .text | 0x10010000 | 37680 |
| .ARM.exidx | 0x10019330 | 8 |
| .copy.table | 0x10019338 | 24 |
| .zero.table | 0x10019350 | 8 |
| .data | 0x080102fc | 1652 |
| .cy_sharedmem | 0x08010970 | 8 |
| .noinit | 0x08010978 | 228 |
| .bss | 0x08010a5c | 1188 |
| .heap | 0x08010f00 | 55552 |
----------------------------------------------------

Total Internal Flash (Available) 262144
Total Internal Flash (Utilized) 39388

CM0+

Calculating memory consumption: CY8C6244LQI-S4D92 GCC_ARM

----------------------------------------------------
| Section Name | Address | Size |
----------------------------------------------------
| .text | 0x10000000 | 32152 |
| .ARM.exidx | 0x10007d98 | 8 |
| .copy.table | 0x10007da0 | 24 |
| .zero.table | 0x10007db8 | 8 |
| .data | 0x08000080 | 1256 |
| .cy_sharedmem | 0x08000568 | 24 |
| .noinit | 0x08000580 | 140 |
| .bss | 0x0800060c | 1096 |
| .heap | 0x08000a58 | 58792 |
----------------------------------------------------

Total Internal Flash (Available) 262144
Total Internal Flash (Utilized) 33480

So overall, CM4 has utilized 15.02% of flash and CM0+ is at 12.77%. I also explored about processor usage - just like we measure CPU speed and usage in PC, but couldn't find an exact method to gauge that. Is it still a feature in MCUs and embedded devices? Not sure if i have seen them in any...

Code

https://github.com/NavadeepGaneshU/AtTheCore_DesignChallenge_PSoC62S4

image

Future Work

Thanks for reading through and hope it was interesting for you all. It was fun working on this project and a super interesting challenge. Dual-core MCUs pose for some very good use cases and with the tools provided by Infineon, the learning curve is attempted to be brought flatter yet the documentation is quite verbose and a lot more things to explore with this kit for me. This project application can be further extended by adding audio intelligence with ML toolbox to implement a door security system with audio/video auth and a plethora of sensors to monitor safety - yet not limited. Looking forward for opportunities like this and I'll be up with this project and will likely be using this device for my upcoming designs. 

References

Infineon/mtb-example-psoc6-low-power-sar-adc-thermistor-als (github.com)
PSoC 6 Peripheral Driver Library: Functions (infineon.github.io)

https://www.infineon.com/dgdl/Infineon-IFX007T-DS-v01_00-EN.pdf

PSoC 6 MCU: CY8C61x4, CY8C62x4 Architecture Technical Reference Manual (TRM) PSoC 61, PSoC 62 MCU (infineon.com) 

Also Read

 AtTheCore: Blog #1 - Intro and what's up with the kit! 

 AtTheCore: Blog #2 - Interfacing LED Bar with ALS 

 AtTheCore: Blog #3 - PWM and Capsense on Cortex M0+ 

 AtTheCore: Blog #4 - Adding shared PWM, Testing with Scope and all about Dual-Core 

  • Sign in to reply
  • navadeepganeshu
    navadeepganeshu over 2 years ago in reply to DAB

    Thanks, DAB! This daunted me a bit while trying to integrate light sensing and capense on different cores and scheduling them properly. Eventually figured out the right way of properly reinitializing the IOs on cores and releasing the locked tasks. A lot of interesting play can be done with this multi-core....haha

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 2 years ago

    Very good update.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube