- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
This time, use the Timer interrupt to set the LED lighting time.
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.
Select the “Pin” tab.
Check P0[3], name it "LED" and select "Drive Mode" as "Strong Drive, Input buffer off".
Move to “peripheral” tab
Check "TCPWM [1] 16bit Timer Counter 0", select Timer-Counter-1.0, and name it "Timer".
The parameter settings are as follows.
Period:10000
Interrupt Source:Overflow & Underflow
Clock Signal:16bit Divider 0 clk
Go to the “Peripheral-Clocks” tab.
Check the 16bit Divider 0 specified in the PWM. Divide by 10,000.
Divider: 10000
Since the clock source is 100MHz, 10KHz divided by 10,000 is output.
Make sure that "TCPWM [1] 16bit Counter (Timer)" is selected as the connection destination of Peripheral.
The program is as follows.
#include "cy_pdl.h"
#include "cyhal.h"
#include "cybsp.h"
#define SWITCH_INTR_PRIORITY (3u)
const cy_stc_sysint_t switch_intr_config = {
.intrSrc = Timer_IRQ, /* Source of interrupt signal */
.intrPriority = SWITCH_INTR_PRIORITY /* Interrupt priority */
};
void Timer_isr(void){
Cy_GPIO_Inv(LED_PORT, LED_NUM);
Cy_TCPWM_ClearInterrupt(Timer_HW, Timer_NUM, CY_TCPWM_INT_ON_TC);
}
int main(void)
{
cy_rslt_t result;
/* Initialize the device and board peripherals */
result = cybsp_init() ;
if (result != CY_RSLT_SUCCESS)
{
CY_ASSERT(0);
}
Cy_TCPWM_Counter_Init(Timer_HW, Timer_NUM, &Timer_config);
Cy_TCPWM_Counter_Enable(Timer_HW, Timer_NUM);
Cy_SysInt_Init(&switch_intr_config, Timer_isr);
NVIC_ClearPendingIRQ(switch_intr_config.intrSrc);
NVIC_EnableIRQ(switch_intr_config.intrSrc);
__enable_irq();
Cy_TCPWM_TriggerStart(Timer_HW, Timer_MASK);
for (;;)
{
}
}
It's easy. First, why don't you get used to Modus toolbox from this program?
Thanks,
- Labels:
-
PSoC 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Kenshow-san,
Thank you very much for your sharing this CE.
Best regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I removed setting explanation of digital output for Pin in first post because it not need it in this example code.
Thanks,
==============================
16-June-2020
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I changed the order in which API functions are called and updated the program.
Thanks,
Kenshow
18-June-2020