Welcome to blog 2 of Neonatal Incubator Monitoring System. In this blog, we will learn how to set up Modus Toolbox 3 for a dual-core application on the PSoC 62S4 pioneer kit and write a simple example that uses both cores to toggle an LED.
Modus Toolbox 3 is an Integrated Development Environment (IDE) that provides a comprehensive suite of tools for developing and debugging applications on Cypress PSoC devices.
Install the Modus Toolbox 3 from the following link and install.
Setting up Modus Toolbox 3
- Connect your PSoC 62S4 pioneer kit to your computer using a USB cable.
- Open Modus Toolbox 3 and click on "File" in the menu bar, then select "New" > "ModusToolbox Application".
- In the "Select Project Type" dialog box, choose "PSoC 6" and click "Next".
- In the "Select Board" dialog box, choose your PSoC 62S4 board and click "Next".
- In the "Configure Application" dialog box, choose "Dual Core Application" and click "Next".
- Follow the remaining prompts to configure your project settings, such as choosing the programming/debugging tool and selecting the peripherals you want to use.
{gallery}My Gallery Title |
---|
Writing a simple dual-core application example
Once you have created your project, you can write a simple example for the dual-core application. Here is an example of how to use both cores to toggle an LED:
CM0:
#include "cy_pdl.h"
#include "cycfg.h"
#include "cyhal.h"
#include "cybsp.h"
int main(void)
{
cy_rslt_t result;
/* Initialize the device and board peripherals */
result = cybsp_init() ;
if (result != CY_RSLT_SUCCESS)
{
CY_ASSERT(0);
}
/* Initialize the RED LED */
result = cyhal_gpio_init(P2_5, CYHAL_GPIO_DIR_OUTPUT,
CYHAL_GPIO_DRIVE_STRONG, CYBSP_LED_STATE_OFF);
if (result != CY_RSLT_SUCCESS)
{
CY_ASSERT(0);
}
/* Enable CM4. CY_CORTEX_M4_APPL_ADDR must be updated if CM4 memory layout is changed. */
Cy_SysEnableCM4(CY_CORTEX_M4_APPL_ADDR);
for (;;)
{
cyhal_gpio_write(P2_5, true);
cyhal_system_delay_ms(1000);
cyhal_gpio_write(P2_5, false);
cyhal_system_delay_ms(1000);
}
}
CM4:
#include "cy_pdl.h"
#include "cyhal.h"
#include "cybsp.h"
int main(void)
{
cy_rslt_t result;
/* Initialize the device and board peripherals */
result = cybsp_init() ;
if (result != CY_RSLT_SUCCESS)
{
CY_ASSERT(0);
}
/* Initialize the Orange LED */
result = cyhal_gpio_init(P2_7, CYHAL_GPIO_DIR_OUTPUT,
CYHAL_GPIO_DRIVE_STRONG, CYBSP_LED_STATE_OFF);
/* User LED init failed. Stop program execution */
if (result != CY_RSLT_SUCCESS)
{
CY_ASSERT(0);
}
/* Blink the LED in loop*/
for (;;)
{
cyhal_gpio_write(P2_7, true);
cyhal_system_delay_ms(250);
cyhal_gpio_write(P2_7, false);
cyhal_system_delay_ms(250);
}
}
In this example, both cores of the PSoC 62S4 microcontroller are utilized to blink the onboard LEDs, P2.5 and P2.7. The Orange LED connected to P2.7, which is programmed on the CM4 core, blinks every 250ms, while the Red LED connected to P2.5, programmed on the CM0 core, blinks every 1000ms.
With Modus Toolbox 3 and the PSoC 62S4 Pioneer Kit, we have successfully set up a dual-core application. In our next blog post, we will discuss the different sensors required to build a baby monitor and how to interface them with this hardware. Thank you for reading, and please stay tuned for more updates.