0 Replies Latest reply on Jun 17, 2020 8:15 PM by NoTa_4591161

    LED and Switch with interrupt - A simple program for beginners using Modus Toolbox2.1 with PSoC6(M4)


      Hi everyone,


      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 it's a simple thing to control LED lighting from SW2 of Kit. It was changed the program using interrupt from LED and Switch - A simple program for beginners using Modus Toolbox2.1 with PSoC6(M4) of previous post.


      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".


      Check P0 [4], name it "SW2", and select Drive Mode "Resistive Pull-Up, Input buffer on". Interrupt Trigger Type set “Falling Edge”.


      The program is written using interrupts as shown below.


      #include "cy_pdl.h"
      #include "cyhal.h"
      #include "cybsp.h“
      const cy_stc_sysint_t switch_intr_config = {
        .intrSrc = ioss_interrupts_gpio_0_IRQn, /* Source of interrupt signal */
        .intrPriority = 3u /* Interrupt priority */
      void Isr_switch(void)
        Cy_GPIO_Inv(LED_PORT, LED_NUM);
        Cy_GPIO_ClearInterrupt(SW2_PORT, SW2_NUM);
      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_SysInt_Init(&switch_intr_config, Isr_switch);
          for (;;) {}




      Now you can easily turn on the LED from SW2.

      It's very easy. First, why don't you get used to Modus toolbox from this program?