Pulse-Division type PWM ?

Hello,

Is RX231 MCU support Pulse-Division type PWM ?

It's from MCU Renesas H8/38076RF.

Thank you

Parents Reply
  • Yes, if its purpose is to generate sound, you can easily implement its function with the DAC unit in RX231 MCU.
     but DAC doesn't need to be filtered like what PWM needs and is much more convenient.  

    To play a sound or tone using DAC, you just need to convert your audio to PCM 8-bit mono format, with a decent sampling rate like 16Khz or higher.  then convert the file to an array of bytes to be used as DAC input data. 

    then the DAC conversion should be triggered at the same rate as the sample rate of the audio. which can be obtained by a timer interrupt. 
     
    I hope you find it useful. if you need help regarding that, don't hesitate to ask. 

    If this or any other user's response answers your concern, kindly verify the answer. Thank you!

    Renesas Engineering Community Moderator
    https://community.renesas.com/
    https://academy.renesas.com/
    en-support.renesas.com/.../

Children
  • Hello Hossein,

    Thank you for your explanation about DAC. I use original source code from H8 MCU they don't use audio file but using base 1 hz it's look like this then they use formula to generate PWM data then output to pin 74. (TBLDT_NUM = 13021)

    The formula :

    1st note

    2nd note

    3rd note

    4th note

    add all note

    Initial value of TXDT_CNTR is 32767. It's look like txdata is value of counter to determine the duty cycle but I'm not sure.

    Out to PWM pin 74

    I want to porting that code to rx231. I'm sorry I cannot share complete source code.

    But I just want to know possiblilty to apply that code to rx231.

    Thank you

  • Hi iamno3, thank you for providing the code snippets, 
     Yes, it's possible to port the code to RX231. 

    The sound is somehow generated and eventually, the final value is passed to the PWM 14-bit unit of the H8. Regardless of the way the sound is generated, we want to generate an analog voltage at a sample time (which I believe is 13Khz in your case), as I can see the 'PWDR1' Register gets updated in each timer interrupt callback. 

    To port the code for RX231, you'll need to substitute the  'PWDR1' register with 'DA.DADR0' which holds the 12-bit data of the DAC channel 0 in the RX231. 
    but you need to divide the value by 4 to transform the 14-bit value to 12-bit. and initialize and start the DAC unit before using the DAC. 

    for example, the code above should be transferred to the code below, and you'll get the same result on the DAC pin. 

    if (flg_txdtin){
    	DA.DADR0 = (uint16_t)((txdtbf / 4) & 0x0FFFU); //Set the DAC channel 0 value
    	flg_txdtin = FLG_OFF;
    }

    If this or any other user's response answers your concern, kindly verify the answer. Thank you!

    Renesas Engineering Community Moderator
    https://community.renesas.com/
    https://academy.renesas.com/
    en-support.renesas.com/.../


     

  • Hello Hossein,

    Sorry for late reply just got back from long holiday.

    Thank you for your explanation. I will try your implementation.

    And will get back when it works.