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.

PWM使能时使能PWM_OUT_0_BIT

在PWM0初始设置了占空比之后,还要用

PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT, true);
 PWMGenEnable(PWM0_BASE, PWM_GEN_0);
来使能PWM发生器,请问PWM_OUT_0_BIT 是什么意思?
如果我换成使能PWM1,的话,PWM_OUT_0_BIT中的0要改成1吗?PWM_GEN_0中的0要改成1吗?
谢谢
  • PWM_OUT_0_BIT,应该是PWM输出0吧,具体可不可以修改,要看头文件中有没有宏定义

  • 数据手册中是可以取上面图中的值的,至于第二个值是什么,库函数中是这么介绍的

    //! Selects the inversion mode for PWM outputs.
    //!
    //! \param ui32Base is the base address of the PWM module.
    //! \param ui32PWMOutBits are the PWM outputs to be modified. This parameter
    //! must be the logical OR of any of \b PWM_OUT_0_BIT, \b PWM_OUT_1_BIT,
    //! \b PWM_OUT_2_BIT, \b PWM_OUT_3_BIT, \b PWM_OUT_4_BIT, \b PWM_OUT_5_BIT,
    //! \b PWM_OUT_6_BIT, or \b PWM_OUT_7_BIT.
    //! \param bInvert determines if the signal is inverted or passed through.
    //!
    //! This function is used to select the inversion mode for the selected PWM
    //! outputs. The outputs are selected using the parameter \e ui32PWMOutBits.
    //! The parameter \e bInvert determines the inversion mode for the selected
    //! outputs. If \e bInvert is \b true, this function causes the specified
    //! PWM output signals to be inverted or made active low. If \e bInvert is
    //! \b false, the specified outputs are passed through as is or made active
    //! high.

  • #define PWM_OUT_0               0x00000040  // Encoded offset address of PWM0
    #define PWM_OUT_1               0x00000041  // Encoded offset address of PWM1
    #define PWM_OUT_2               0x00000082  // Encoded offset address of PWM2
    #define PWM_OUT_3               0x00000083  // Encoded offset address of PWM3
    #define PWM_OUT_4               0x000000C4  // Encoded offset address of PWM4
    #define PWM_OUT_5               0x000000C5  // Encoded offset address of PWM5
    #define PWM_OUT_6               0x00000106  // Encoded offset address of PWM6
    #define PWM_OUT_7               0x00000107  // Encoded offset address of PWM7
    
    #define PWM_OUT_0_BIT           0x00000001  // Bit-wise ID for PWM0
    #define PWM_OUT_1_BIT           0x00000002  // Bit-wise ID for PWM1
    #define PWM_OUT_2_BIT           0x00000004  // Bit-wise ID for PWM2
    #define PWM_OUT_3_BIT           0x00000008  // Bit-wise ID for PWM3
    #define PWM_OUT_4_BIT           0x00000010  // Bit-wise ID for PWM4
    #define PWM_OUT_5_BIT           0x00000020  // Bit-wise ID for PWM5
    #define PWM_OUT_6_BIT           0x00000040  // Bit-wise ID for PWM6
    #define PWM_OUT_7_BIT           0x00000080  // Bit-wise ID for PWM7

    应该是8路PWM的选择吧