This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

pwm

I am new to XC164 and to PWM. I am trying to control some DC motors.
Does anybody has any software examples on how to implement PWMs on CAPCOM1/2 and CAPCOM6 on XC164 micro?
Also, does anybody know how many simple and independent PWMs can be implemented using XC164 micro?

Thank you,
Oliver

  • Take a look to the Infineon web side. I think that have some application notes there.

  • try to configure the pwm-module by using Dave. That helped me a lot.

    ...Leo

  • To Oliviu Condurache

    Hi Oliviu
    I have the same problem.
    I need 4 indipendent PWMs using XC164.
    If you have a solution, please contact me.

    Thanks
    Paolo

    automazione@geco-group.it

  • void vInitCoilsAndDigitalOutputs( void )
    /*******************************************************************************
    Description:  This routine initializes the CAPCOM units. The PWM output channels
                  (CC0IO-CC7IO) are initialized to operate in mode 3.  The DC
                  channels (CC16IO-CC23IO) are initialized to operate in mode 2,
                  this allows port 8 outputs to be controlled as digital outputs
                  rather than frequency outputs.
    Inputs:  NONE
    Outputs: NONE
    Globals:
    *******************************************************************************/
    {
       /* Setup the port bits*/
       /* Make the outputs for drivers 0 through 5 outputs (6&7 should be inputs).
          Don't mess with the   other bits.  Make sure they are in push/pull mode.
          Don't mess with those   other bits either.  A one in DP2 makes that bit an
          output.  A zero in ODP2   makes that bit push/pull.*/
       DP2 |= 0x0003F;
       ODP2 &= 0x0FF00;
    
       /* Make the outputs for drivers 16 through 23 outputs.
          Make sure they are in push/pull mode.
          A one in DP8 makes that bit an output.  A zero in ODP8 makes that bit
          push/pull.  These are only 8 bit registers, so we don't have to worry
          about the other bits.  (Also config port 7.4 which is the neutral relay).
       */
       DP8 = 0x000FF;
       ODP8 = 0x00000;
       P8 = 0x007F; /* Turn all digital outputs off EXCEPT CC23IO (ISO_PWR_ENA) */
       m_bitPort7_4_DIR = 1;
       m_bitPort7_4_TYP = 0;
       m_bitPort7_4 = 1; /* Make sure neutral relay is off */
    
       /* Initialize the timers*/
       /* Timer reload register values*/
       T0REL = T7REL = COIL_RELOAD;
    
       /* Set the timer input selection
          All timers are driven from the CPU clock*/
       m_bitT0I0 = m_bitT0I1 = m_bitT0I2 = 0;
       m_bitT7I0 = m_bitT7I1 = m_bitT7I2 = 0;
    
       /* Both timers are in timer mode*/
       T0M = T7M = 0;
    
       /* Initialize the PWM output channels (CC0IO-CC7IO)*/
       CCM0 = CCM1 = CCMX_INIT_PWM_OUTPUTS;
    
       /* Initialize the DC output channels (CC16IO-CC23IO, CC28IO)*/
       CCM4 = CCM5 = CCMX_INIT_DC_OUTPUTS;
       CCM7 |= INIT_DC_OUPUT;
    
       /* Set all the output values to off*/
       CC0  = CC1  = CC2  = CC3  = CC4  = CC5  = CC6  = CC7  = COIL_OFF;
       CC16 = CC17 = CC18 = CC19 = CC20 = CC21 = CC22 = CC23 = CC28 = COIL_OFF;
    
       /* Enable the timers*/
       T0R = T7R = 1;
    }/* vInitCoilsAndDigitalOutputs() */
    
    

  • /* This defines the timer reload value.  The actual value is based on the
       selected resolution.  The maximum valve coil value is also set up here.
       Passing a value greater than MAX_COIL_VAL to the valve coil driver output
       functions will generate a runtime error.*/
    #define COIL_RELOAD  0x0FC00     /* 2.441 KHz output frequency*/
    #define MAX_COIL_VAL 0x003FE
    #define OFFSET_VAL   48
    
    /* The PWM outputs are controlled by CAPCOM channels 0 through 7. This word is
       programmed into registers CCM0 and CCM1 so that these channels operate in
       compare mode 3 and are allocated to timers T0 and T7.*/
    #define CCMX_INIT_PWM_OUTPUTS    0x07777;
    
    
    /* The DC outputs are controlled by CAPCOM channels 16 through 23. This word is
       programmed into registers CCM4 and CCM5 so that these channels operate in
       compare mode 2 and are allocated to timers T0 and T7.  In compare mode 2, the
       output pin is unaffected by an interrupt and therefor the output can be used
       as a dc output.*/
    #define CCMX_INIT_DC_OUTPUTS   0x06666;
    #define INIT_DC_OUPUT          0x06;