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.

LM4F用定时器产生PWM如何设置反相

LM4F用定时器产生PWM如何设置反相

数据手册里面,(TnPWML =1 时)这一位在哪设置,头文件里面没找着对应的函数啊?

  • 这个函数不是设置初始电平的吗?
    TimerControlLevel(TIMER0_BASE, TIMER_B,true);

  • 你可以看看函数原型,操作的是什么寄存器呢。WARE开发包中应该有pwm.c文件的。

  • //*****************************************************************************
    //
    //! Controls the output level.
    //!
    //! \param ui32Base is the base address of the timer module.
    //! \param ui32Timer specifies the timer(s) to adjust; must be one of
    //! \b TIMER_A, \b TIMER_B, or \b TIMER_BOTH.
    //! \param bInvert specifies the output level.
    //!
    //! This function configures the PWM output level for the specified timer. If
    //! the \e bInvert parameter is \b true, then the timer's output is made active
    //! low; otherwise, it is made active high.
    //!
    //! \return None.
    //
    //*****************************************************************************
    void
    TimerControlLevel(uint32_t ui32Base, uint32_t ui32Timer, bool bInvert)
    {
    //
    // Check the arguments.
    //
    ASSERT(_TimerBaseValid(ui32Base));
    ASSERT((ui32Timer == TIMER_A) || (ui32Timer == TIMER_B) ||
    (ui32Timer == TIMER_BOTH));

    //
    // Set the output levels as requested.
    //
    ui32Timer &= TIMER_CTL_TAPWML | TIMER_CTL_TBPWML;
    HWREG(ui32Base + TIMER_O_CTL) = (bInvert ?
    (HWREG(ui32Base + TIMER_O_CTL) |
    ui32Timer) :
    (HWREG(ui32Base + TIMER_O_CTL) &
    ~(ui32Timer)));
    }