2 Replies Latest reply on Jun 11, 2018 5:14 PM by user_265343250

    PSoC 6 WiFi-BT Kit map PWM to GPIO

    user_265343250

        I've been trying to map  WICED_PWM_3 to WICED_GPIO_9 pin on the PSoC6 WiFi BT kit for a RC servo motor not having any luck.  I was able to map it on the PSoC BLE kit using PSoC Creator without any issue.  I've tried modifying the follow code in platform.c but it doesn't seem to work.

       

      const platform_pwm_t platform_pwm_peripherals[] =
      {
      [WICED_PWM_1] = PLATFORM_PWM_COMPL(0, 1, WICED_GPIO_4, 0, 3),
      [WICED_PWM_2] = PLATFORM_PWM_COMPL(0, 3, WICED_GPIO_8, 1, 1),
      [WICED_PWM_3] = PLATFORM_PWM_COMPL(1, 1, WICED_GPIO_78, 11, 1),

       

      to

       

      const platform_pwm_t platform_pwm_peripherals[] =
      {
      [WICED_PWM_1] = PLATFORM_PWM_COMPL(0, 1, WICED_GPIO_4, 0, 3),
      [WICED_PWM_2] = PLATFORM_PWM_COMPL(0, 3, WICED_GPIO_8, 1, 1),
      [WICED_PWM_3] = PLATFORM_PWM_COMPL(1, 1, WICED_GPIO_9, 11, 1),

       

      I get it to build but if I change the port to 1 and the pin number to 2 it fails to build see build errors below.  I'm not sure what values I should use for _block_ and _cntr_

       

      Compiling Platform_CY8CKIT_062
      platforms/CY8CKIT_062/platform.c:343:17: error: 'P1_2_TCPWM1_LINE_COMPL1' undeclared here (not in a function); did you mean 'P11_1_TCPWM1_LINE_COMPL1'?
      .hsiom = P ## _port_ ## _ ## _pin_ ## _TCPWM ## _block_ ## _LINE_COMPL ## _cntr_
      ^
      platforms/CY8CKIT_062/platform.c:359:7: note: in expansion of macro 'PWM_PIN_ELEM_COMPL'
      PWM_PIN_ELEM_COMPL(_block_, _cntr_, _wiced_gpio_port_, _wiced_gpio_pin_) \
      ^~~~~~~~~~~~~~~~~~
      platforms/CY8CKIT_062/platform.c:370:22: note: in expansion of macro 'PLATFORM_PWM_COMPL'
      [WICED_PWM_3] = PLATFORM_PWM_COMPL(1, 1, WICED_GPIO_9, 1, 2),
      ^~~~~~~~~~~~~~~~~~
      platforms/CY8CKIT_062/platform.c:343:17: error: 'P1_2_TCPWM1_LINE_COMPL1' undeclared here (not in a function); did you mean 'P11_1_TCPWM1_LINE_COMPL1'?
      .hsiom = P ## _port_ ## _ ## _pin_ ## _TCPWM ## _block_ ## _LINE_COMPL ## _cntr_
      ^
      platforms/CY8CKIT_062/platform.c:359:7: note: in expansion of macro 'PWM_PIN_ELEM_COMPL'
      PWM_PIN_ELEM_COMPL(_block_, _cntr_, _wiced_gpio_port_, _wiced_gpio_pin_) \
      ^~~~~~~~~~~~~~~~~~
      platforms/CY8CKIT_062/platform.c:370:22: note: in expansion of macro 'PLATFORM_PWM_COMPL'
      [WICED_PWM_3] = PLATFORM_PWM_COMPL(1, 1, WICED_GPIO_9, 1, 2),
      ^~~~~~~~~~~~~~~~~~
      make.exe[3]: *** [build/waf.sflash_write-NoOS-CY8CKIT_062-SDIO/Modules/platforms/CY8CKIT_062/platform.o] Error 1
      tools/makefiles/wiced_elf.mk:232: recipe for target 'build/waf.sflash_write-NoOS-CY8CKIT_062-SDIO/Modules/platforms/CY8CKIT_062/platform.o' failed
      make.exe[2]: *** [main_app] Error 2
      Makefile:351: recipe for target 'main_app' failed
      make.exe[1]: *** [sflash_write_app] Error 2
      tools/makefiles/wiced_apps.mk:415: recipe for target 'sflash_write_app' failed
      make.exe[1]: *** Waiting for unfinished jobs....
      make.exe[3]: *** [build/waf.bootloader-NoOS-CY8CKIT_062/Modules/platforms/CY8CKIT_062/platform.o] Error 1
      make.exe[2]: *** [main_app] Error 2
      make.exe[1]: *** [bootloader] Error 2
      tools/makefiles/standard_platform_targets.mk:90: recipe for target 'bootloader' failed
      make: *** [main_app] Error 2
      Makefile:351: recipe for target 'main_app' failed

       

      I tried to follow the Macros but not having any luck.  Any help would be greatly appreciated. 

        • 1. Re: PSoC 6 WiFi-BT Kit map PWM to GPIO
          msur

          Hello,

           

          The reason for the error is P1.2 does not support PWM_LINE_COMPL connection and the TCPWM counter you tried to place on P1.2 is invalid as well.

           

          A rule of thumb is - even pins support PWM_LINE connections and odd pins support PWM_LINE_COMPL connections. If you use P1.1, then the project should build fine.

           

          Another important thing to note is, you need to understand which pin has which TCPWM block's counter connection. You can find the details in the datasheet (Table 2, Act#0 for TCPWM block 0 and Act#1 for TCPWM block 1) and the macro definitions can be found in the "gpio_psoc62_124_bga.h" file. This info is required for selecting the appropriate value for the first two parameters. For instance, if you want a pwm's complimentary output on P1.1 (note P1.2 does not support a complimentary output), then you need to use - PLATFORM_PWM_COMPL(1, 3, WICED_GPIO_9, 1, 1) for it to compile. This info can be found in the device datasheet - use Act#1 column of Table 2, if you want to use TCWPM block#1 (16-bit PWM) and Act#0 for TCPWM block#0 (32-bit PWM). Once you know the pin you want to use, go to the row against the pin. In the Act#0 or #1 column, you would find something like "tcpwm[m].line_compl[n]" (ignore the number after ':'). In this description, 'm' denotes the TCPWM block# and 'n' denotes the counter number to use. If it says line_compl, then it supports complimentary PWM output (PWM output is inverted/complimented before sending out). Otherwise it should just say "line", which means it supports normal PWM output.

           

          Let me know if this helps.

           

          Regards,

          Meenakshi Sundaram R

          1 of 1 people found this helpful
          • 2. Re: PSoC 6 WiFi-BT Kit map PWM to GPIO
            user_265343250

            Thank you so much for a very clear answer to my issue.  I changed the code to following and everything is working now.

             

             

                [WICED_PWM_3]  = PLATFORM_PWM(0, 4, WICED_GPIO_9, 1, 2),

             

            Thank you for the link to the datasheet and a very clear understanding on how to map a PWM

             

            Jeff