Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

PSoC™ 6 Forum Discussions

YSJE_3566666
Level 4
25 replies posted 100 sign-ins 50 sign-ins
Level 4

Hello,
I have questions about HAL / PDL driver.

1. I know that PDL is configurable through device configurator.
But let's take the case of using HAL as an example.

In cyhal_pwm_init_adv() function of cyhal_pwm.c, PWM is already set in cy_stc_tcpwm_pwm_config_t pdl_config = {}.

cy_stc_tcpwm_pwm_config_t pdl_config =
{
.pwmMode = (dead_time == 0) ? CY_TCPWM_PWM_MODE_PWM : CY_TCPWM_PWM_MODE_DEADTIME,
.clockPrescaler = CY_TCPWM_PWM_PRESCALER_DIVBY_1,
.pwmAlignment = pdl_alignment,
.deadTimeClocks = dead_time,
.runMode = (continuous) ? CY_TCPWM_PWM_CONTINUOUS : CY_TCPWM_PWM_ONESHOT,
.period0 = 0UL,
.period1 = 0UL,
.enablePeriodSwap = false,
.compare0 = 0UL,
.compare1 = 0UL,
.enableCompareSwap = false,
.interruptSources = CY_TCPWM_INT_NONE,
.invertPWMOut = (invert) ? CY_TCPWM_PWM_INVERT_ENABLE : CY_TCPWM_PWM_INVERT_DISABLE,
.invertPWMOutN = (invert) ? CY_TCPWM_PWM_INVERT_ENABLE : CY_TCPWM_PWM_INVERT_DISABLE,
.killMode = CY_TCPWM_PWM_STOP_ON_KILL,
.swapInputMode = CY_TCPWM_INPUT_RISINGEDGE,
.swapInput = CY_TCPWM_INPUT_0,
.reloadInputMode = CY_TCPWM_INPUT_RISINGEDGE,
.reloadInput = CY_TCPWM_INPUT_0,
.startInputMode = CY_TCPWM_INPUT_RISINGEDGE,
.startInput = CY_TCPWM_INPUT_0,
.killInputMode = CY_TCPWM_INPUT_RISINGEDGE,
.killInput = CY_TCPWM_INPUT_0,
.countInputMode = CY_TCPWM_INPUT_LEVEL,
.countInput = CY_TCPWM_INPUT_1
};

Do I have to edit this manually to change the PWM config?
It seems the PDL is set via the device configurator, but the HAL is not.
Also, cyhal_pwm.c is a file in mtb_shared, so I don't think the user should change it.

2. Many examples of Modus are made up of HAL driver.
Are there examples implemented in PDL for various peripherals?

Best Regards,
YS

0 Likes
1 Solution
Srivastav
Moderator
Moderator 25 replies posted First like given 25 sign-ins
Moderator

Hi,

You can change the contents of HAL as per your application but there’s a specific process that you need to follow.

  1. Workspace name = SPI which contains two projects SPI_Master and Hello_World. These two projects are getting HAL from MTB Shared folder. (Refer Image 1 and 2 for more details).
  2. If change the contents of HAL in mtb shared folder then all those changes will reflect in all the projects (SPI_Master and Hello_World both) of the workspace (SPI). So, if you want that the changes made by you in the HAL should reflect to all the projects, you can directly change HAL.
  3. In case you want that the changes made by you should be specific to one particular project then you need to go to Library Manager and import HAL to that specific project.
  4. Click on Library Manager > Libraries and then uncheck the Shared checkbox for HAL and then click on update.
  5. You will see mtb-hal-cat1 folder local to that Particular project for which you imported HAL. (Refer to image 3_Before, HAL_Shared_Checkbox, 3_After for more details)
  6. Now you can change the contents of the newly imported HAL which is local to one specific project as per your requirement and these changes will be local to one project only not the whole workspace.

 

Kind Regards

Arpit Srivastav

View solution in original post

0 Likes
3 Replies
Srivastav
Moderator
Moderator 25 replies posted First like given 25 sign-ins
Moderator

Hi,

Please refer to PSoC 6 PDL API Refernce https://infineon.github.io/psoc6pdl/pdl_api_reference_manual/html/modules.html and here you can find how to implement CAN FD, I2S, I2C, SPI, etc. using PDL for PSoC 6 devices.

Please refer to PSoC 4 PDL API Reference https://infineon.github.io/psoc4pdl/pdl_api_reference_manual/html/modules.html  and here you can find how to implement CAN FD, I2S, I2C, SPI, etc. using PDL for PSoC 4 devices.

You can also refer to our github page https://github.com/Infineon/Code-Examples-for-ModusToolbox-Software for PSoC 6 and PSoC 4 code examples.

Kind Regards

Arpit Srivastav

0 Likes
Srivastav
Moderator
Moderator 25 replies posted First like given 25 sign-ins
Moderator

Hi,

You can change the contents of HAL as per your application but there’s a specific process that you need to follow.

  1. Workspace name = SPI which contains two projects SPI_Master and Hello_World. These two projects are getting HAL from MTB Shared folder. (Refer Image 1 and 2 for more details).
  2. If change the contents of HAL in mtb shared folder then all those changes will reflect in all the projects (SPI_Master and Hello_World both) of the workspace (SPI). So, if you want that the changes made by you in the HAL should reflect to all the projects, you can directly change HAL.
  3. In case you want that the changes made by you should be specific to one particular project then you need to go to Library Manager and import HAL to that specific project.
  4. Click on Library Manager > Libraries and then uncheck the Shared checkbox for HAL and then click on update.
  5. You will see mtb-hal-cat1 folder local to that Particular project for which you imported HAL. (Refer to image 3_Before, HAL_Shared_Checkbox, 3_After for more details)
  6. Now you can change the contents of the newly imported HAL which is local to one specific project as per your requirement and these changes will be local to one project only not the whole workspace.

 

Kind Regards

Arpit Srivastav

0 Likes
YSJE_3566666
Level 4
25 replies posted 100 sign-ins 50 sign-ins
Level 4

Hi Srivastav,

Thank you for your help.

Best Regards,
YS

0 Likes