This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM625: pwm beeper dts binding for am625

Part Number: AM625

Hi 

We are working oncustom board based am62xx-sk and buzzer connected on one of the pin (Ball no B21-Mode2).

We Need to control the buzzer output using PWM. i.e similar to controlling lcd backlight.

There is a dts binding available for same in am437x based custom board, which modified to support in am62xx custom board.

main_pwm2: dmtimer-main-pwm-2 {
compatible = "ti,omap-dmtimer-pwm";
pinctrl-names = "default";
pinctrl-0 = <&main_ecap1_capture_pins_default>;
ti,timers = <&main_timer2>;
#pwm-cells = <3>;
};

beeper: beeper {
compatible = "pwm-backlight";
/*compatible = "pwm-beeper";*/
/* 5000 here is the total T represented in micro-seconds */
pwms = <&main_pwm2 0 500000000 0>;
/* 0 to 255 represent the duty cycle, 255 being the max and 127.5 would be a perfect 50% duty cycle */
brightness-levels = <0 50 75 100 125 150 175 200 225 255>;
default-brightness-level = <4>;
post-pwm-on-delay-ms = <500>;
pwm-off-delay-ms = <100>;
status = "okay";
};

  main_ecap1_capture_pins_default: main-ecap1-capture-pins-default {
pinctrl-single,pins = <
AM62X_IOPAD(0x022C, PIN_OUTPUT, 2) /* (B21) MMC1_DAT1 /ECAP1_IN_APWM_OUT/TIMER_IO2 */
>;
};

There is no change in buzzer output when change the brightness value for /sys/class/backlight/beeper.

I need support in debugging this issue and inputs.

I also tried using ecap_pwm dts node on the same pin.

&ecap1_pwm {
status = "okay";
 pinctrl-names = "default";
pinctrl-0 = <&main_ecap1_capture_pins_default>;
};

main_ecap1_capture_pins_default: main-ecap1-capture-pins-default {
pinctrl-single,pins = <
AM62X_IOPAD(0x022C, PIN_OUTPUT, 4) /* (B21) MMC1_DAT1 /ECAP1_IN_APWM_OUT/TIMER_IO2 */
>;
};

I am able to configure the duty cycle, Here i am getting square wave changing as per duty cycle. But there is no change in buzzer output.  

https://software-dl.ti.com/processor-sdk-linux/esd/AM62X/08_03_00_19/exports/docs/linux/Foundational_Components/Kernel/Kernel_Drivers/PWM.htm 

  • Hello,

    I am not sure I understand the question. It sounds like you are able to change the duty cycle of the ECAP PWM output, and you are able to verify with an oscilloscope that the square wave getting output is also changing in duty cycle?

    I can help you change the PWM output coming out of the AM62x, but I will not be able to comment on how a peripheral outside of the AM62x uses that changed PWM output. One potential thing I can think of though: How does the buzzer work? e.g., if the buzzer works by changing the frequency of the PWM output signal instead of the duty cycle, then changing the duty cycle will not change the buzzer behavior.

    For some additional information on ECAP PWM, reference https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1256467/sk-am62-ecap-pwm-not-working-on-custom-board-based-on-am62xx-sk/4790485#4790485

    Regards,

    Nick

  • I am not sure I understand the question. It sounds like you are able to change the duty cycle of the ECAP PWM output, and you are able to verify with an oscilloscope that the square wave getting output is also changing in duty cycle?

    yes square wave output also changes with duty cycle.

    One potential thing I can think of though: How does the buzzer work? e.g., if the buzzer works by changing the frequency of the PWM output signal instead of the duty cycle, then changing the duty cycle will not change the buzzer behavior.

    How to change the behaviour? We tused same way on other hardware based on am437x , where i will change the brightness which is mapped particulat duty cycle(pwm-backlight). 

  • Hello Siva,

    I can support the AM625x, but I cannot support whatever buzzer you are using (unless it is a TI part). I can help you get the signal coming out of the AM625x to behave a certain way. But once the AM625x output signal is doing exactly what you want it to do, I cannot tell you how a different part will react to that signal.

    Since you want to change the duty cycle of the PWM output, and you are generating a PWM signal where you can control the duty cycle, there is not much else I can help you with.

    If there are any followup questions that we can be of assistance with though, feel free to reply here (or create a new thread if the question is about a different topic).

    Regards,

    Nick

  • I can share u-boot source code diagnostics CLI snippet where B21 pin i.e Timer02 with 0%,50%,100% duty cycle. Here i can clearly see the difference of buzzer output. 

    based on that i need values need to be updated in /sys/ filesystem to get same output using ecap_pwm. 

  • Hello Siva,

    When you use an oscilloscope to measure the PWM output in u-boot, does it look different from the output from the ecap PWM output? If so, what is the difference between the signals?

    Regards,

    Nick

  • Main difference is the TimePeriod/Frequency.  in uboot B21 Configured as Timer02, Registers are updated for frequency of 1.5KHZ & 0%,50%,100% duty cycle.

    In case of ecap1_pwm i can no configure period less than 100ms i.e 0.01kHZ.

    This is there reason in previous products use timer based PWM where i can configure the TimePeriod for PWM in dts.

    u-boot snippet(100% duty cycle);

    #define TIMERIO2_TLDR (TIMERIO2_BASE + 0x40)
    #define TIMERIO2_TMAR (TIMERIO2_BASE + 0x4C)
    #define TIMERIO2_TCRR (TIMERIO2_BASE + 0x3C)
    #define TIMERIO2_TIOCP_CFG (TIMERIO2_BASE + 0x10)

    #define COUNTER_PERIOD (0xFFFFE120) /* Period : 1KHz */
    #define COUNTER_DUTY (0xFFFFEF8F) /* Duty cycle : 50% */
    #define PWM_CONFIG_TCLR (0x00001862) /* Setting in TCLR register : PT, TRG, TCM, SCPWM,CE, PRE, PTV, AR */
    #define PWM_ENABLE_TCLR (0x00001863) /* Enable PWM timer : Setting ST bit */

    __raw_writel(0X0000000, TIMERIO2_TCLR); // stop timer
    __raw_writel(PWM_CONFIG_TCLR, TIMERIO2_TCLR); // Configuting the timer
    __raw_writel(COUNTER_PERIOD_100, TIMERIO2_TLDR); // Setting period
    __raw_writel(COUNTER_PERIOD_100, TIMERIO2_TCRR);
    __raw_writel(0x08, TIMERIO2_TIOCP_CFG);
    __raw_writel(COUNTER_DUTY_100, TIMERIO2_TMAR); // setting the duty cycle

  • Hi Siva,

    our PWM/ECAP expert is out of the office until e/o October so further responses here will be delayed. If you make any progress debugging this yourself please keep the thread here up-to-date. You could also look at our AM62x MCU+ SDK and the examples included there to see/understand low-level timer access/handling, and use this to debug/understand the HW behavior and then port/apply whatever you need to U-Boot/Linux.

    Regards, Andreas

  • Hello Siva,

    Apologies for the delay. I am back in the office. Do you still need assistance here?

    Regards,

    Nick

  • Hi Nick

    we are unable to configure 1.5kHZ using epwm. 

    Regards,

    Siva.

  • Hello Siva,

    Understood. Will take a look on Monday and get back to you.

    Regards,

    Nick

  • Hello Siva,

    "There is no change in buzzer output when change the brightness value for /sys/class/backlight/beeper."

    Please post how you are changing your brightness value. I seem to remember a brightness setting that we were changing from 0-7 thinking that it was moving between entries in "brightness-levels", but it was actually changing from 0-7 on a scale of 0-255. I am curious if something similar could be happening here.

    "I am able to configure the duty cycle, Here i am getting square wave changing as per duty cycle. But there is no change in buzzer output."

    Can you please provide additional information here? Help me to see what you are seeing.
     * How are you configuring the duty cycle?
     * What are the screenshots or images showing the square wave changing as per your different duty cycle settings?

    "/* 5000 here is the total T represented in micro-seconds */
    pwms = <&main_pwm2 0 500000000 0>;"

    Did you intend to set a single period to be 500,000,000 micro-seconds, or 1 period per 500 seconds? Or did you change this value?

    Regards,

    Nick