Modus Toolbox recommended APIs

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

cross mob
benjaminpaik
Level 2
Level 2
10 questions asked 10 sign-ins 5 questions asked

I've noticed that the Modus Toolbox tutorial videos demonstrate a different approach to interfacing with peripherals that what is shown in the Modus Toolbox example projects. For example, the video tutorials demonstrate configuration of the PWM with functions Cy_TCPWM_PWM_Init, Cy_TCPWM_PWM_Enable, Cy_TCPWM_TriggerStart, etc. The "PWM_Square_Wave" example project on the other hand uses cyhal_pwm_init,  cyhal_pwm_set_duty_cycle,  cyhal_pwm_start, etc. What is the difference between these APIs and which is recommended for custom applications? With my limited experience, I prefer the paradigm from the video tutorials since it appears less verbose and seems to work better with the device configurator. However, I would want to adopt whatever paradigm is officially endorsed rather than becoming dependent on something that will be phased out in the future.

0 Likes
1 Solution
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi @benjaminpaik

The APIs that you are referring to are part of the two flows - 

  • PDL (Peripheral Driver Library) which includes -  Cy_TCPWM_PWM_Init, Cy_TCPWM_PWM_Enable, Cy_TCPWM_TriggerStart, etc.
  • HAL (Hardware Abstraction Layer) which includes - cyhal_pwm_init,  cyhal_pwm_set_duty_cycle,  cyhal_pwm_start, etc.

Which flow to use depends on the application that you are working on. HAL is beginner-friendly, requires fewer APIs, and helps in keeping your application device agnostic. However, if you need finer control you will have to switch to PDL.

These threads on similar discussions will help you in clearing the confusion -

Running Hello World with CY8CKIT-062-WiFi-BT using Modus Toolbox 

Device Configurator and HAL/ PDL compatibility - use cases 

which pins should be defined in Device Configurator and which pins should not?

This training will help you understand the HAL and PDL flow - Session 2: Introduction to Digital Peripherals in ModusToolbox

Thanks and Regards,
Rakshith M B

View solution in original post

1 Reply
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi @benjaminpaik

The APIs that you are referring to are part of the two flows - 

  • PDL (Peripheral Driver Library) which includes -  Cy_TCPWM_PWM_Init, Cy_TCPWM_PWM_Enable, Cy_TCPWM_TriggerStart, etc.
  • HAL (Hardware Abstraction Layer) which includes - cyhal_pwm_init,  cyhal_pwm_set_duty_cycle,  cyhal_pwm_start, etc.

Which flow to use depends on the application that you are working on. HAL is beginner-friendly, requires fewer APIs, and helps in keeping your application device agnostic. However, if you need finer control you will have to switch to PDL.

These threads on similar discussions will help you in clearing the confusion -

Running Hello World with CY8CKIT-062-WiFi-BT using Modus Toolbox 

Device Configurator and HAL/ PDL compatibility - use cases 

which pins should be defined in Device Configurator and which pins should not?

This training will help you understand the HAL and PDL flow - Session 2: Introduction to Digital Peripherals in ModusToolbox

Thanks and Regards,
Rakshith M B