Skip to content

Core api update tone #351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: core-api-update
Choose a base branch
from
Open

Conversation

dineshgit411
Copy link

By creating this pull request you agree to the terms in CONTRIBUTING.md.
https://github.com/Infineon/.github/blob/master/CONTRIBUTING.md
--- DO NOT DELETE ANYTHING ABOVE THIS LINE ---

CONTRIBUTING.md also tells you what to expect in the PR process.

Description
Tone function implemented using PWM method. In XMC we have two modes CCU4 and CCU8 . configured for all the PWM pins.

Related Issue
Removed delay in test_main.ino because test case not running in continuous loop.
Context
Tested with 4700 Board, connected jumber wire in between interrupt pin and pwm pin.
image

Copy link
Collaborator

@LinjingZhang LinjingZhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!
dicussed in the call, Tont will be merged first and then the analog function.

Copy link
Member

@jaenrig-ifx jaenrig-ifx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good 👍

XMC_GPIO_MODE_OUTPUT_PUSH_PULL | pwm4->port_mode);
XMC_CCU4_SLICE_StartTimer(pwm4->slice);
// count pulses for stop the timer once reached required pulses
if (duration > 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if a duration is set the function is blocking or?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, I will change the logic. before, I used timer but one test case got failed due to time variation(100ms)
I will revisit and change.

@@ -73,6 +73,8 @@ extern "C" {

#define interrupts() __enable_irq()
#define noInterrupts() __disable_irq()
#define ENABLED 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are these defines used?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In pins_arduino.h for ADC and PWM pins configurationsL like here: https://github.com/Infineon/XMC-for-Arduino/blob/master/variants/XMC4700/config/XMC4700_Relax_Kit/pins_arduino.h#L331
Maybe modify macro to be XMC_ENABLED or simply use false/true for all xmc struct.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the naming is too generic for potential conflict with any other code not coming from XMC deciding to declare such.
We have already experienced that with macros like GPIO, ADC and such.
They help to understand more what that flag/variable does. But this is also not user level code, so maybe the simplest is to stay with true and false :)

@LinjingZhang LinjingZhang self-requested a review June 11, 2025 12:50
Copy link
Collaborator

@LinjingZhang LinjingZhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the two issues juan mentioned need to be fixed

  1. tone(duration) should not be blocking call -> maybe this is reason of scheduler code in timer module?
  2. true and false instad of ENABLED and DISABLED macro.

dineshgit411 and others added 8 commits June 13, 2025 18:15
Signed-off-by: MDin <Dinesh.M-EE@infineon.com>
Signed-off-by: MDin <Dinesh.M-EE@infineon.com>
Signed-off-by: MDin <Dinesh.M-EE@infineon.com>
Signed-off-by: MDin <Dinesh.M-EE@infineon.com>
Signed-off-by: MDin <Dinesh.M-EE@infineon.com>
Signed-off-by: MDin <Dinesh.M-EE@infineon.com>
Signed-off-by: MDin <Dinesh.M-EE@infineon.com>
Signed-off-by: zhanglinjing <Linjing.Zhang@infineon.com>
@LinjingZhang LinjingZhang force-pushed the core-api-update-tone branch from 0582e0f to 2911542 Compare June 13, 2025 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants