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.

MSP432E401Y: PWM外设的频率问题

Part Number: MSP432E401Y

Technical Reference似乎表示了不同的PWM Generator可以采用不同的波形频率。

然而我在使用TI-drivers时无法使不同发生器的PWM采用不同频率。我该如何解决?

此外,MSP432E4系列的产品的timer的PWM_MODE产生的波形是否有占空比为50%的限制?

  • 您是否有参考TI例程:

    simplelink_msp432e4_sdk_4_20_00_12\examples\nortos\MSP_EXP432E401Y\driverlib\pwm_genx_syncgenerators 

  • 你好 这是driverlib的例程 然而在TI drivers在PWM_open()内使用不同的频率或周期可能会出现问题。

  • 可能会出现问题

    请问能否说一下具体是什么问题?是会在编译时报错还是可以编译成功但使用时功能不正常?

    若是可以,能否给出完整代码,我在开发板上测试一下

  • 可以过编译。然而PWM_open()的返回值是NULL.具体情况是在PWMMSP432E4.c里initHw()中 此处返回的错误导致。我这里尽管使用了不同generator的引脚,可是只要频率不同就无法打开PWM。我该如何向你发送代码?

  • 我该如何向你发送代码?

    您应该会收到我发给您的消息吧,直接回复即可。使用附件压缩包的方式上传,谢谢

  • 抱歉,我这边找了一下,没有MSP432E的板子,所以我是使用MSP432P系列来测试的

    代码如下,不建议您在循环内打开PWM,即

    /*** - custom variables end - ***/
    for(int i=0;i<CONFIG_PWM_COUNT;i++){
    pwmHandle[i] = PWM_open(i, pwmParams+i);
    if(pwmHandle[i]==NULL){
    //error: PWM did not open
    //there had better a UART output
    while(1);
    }

    而是尝试逐个打开

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /*
    * Copyright (c) 2015-2019, Texas Instruments Incorporated
    * All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * * Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * * Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    *
    * * Neither the name of Texas Instruments Incorporated nor the names of
    * its contributors may be used to endorse or promote products derived
    * from this software without specific prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • 能讲一下原因吗

  • 您可以看一下下面链接的 

    MPS432 PWM Driver Configuration

    http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/SIMPLELINK_MSP432_SDK/1.20.00.45/exports/docs/tidrivers/doxygen/html/_p_w_m_timer_m_s_p432_8h.html 

    以及说明:

    • Only one PWM index can be used at a time; calling PWM_open() a second time with the same index previously passed to PWM_open() will result in an error. You can, though, re-use the index if the instance is closed via PWM_close(). In the example code, Board_PWM0 is passed to PWM_open(). This macro is defined in the example's Board.h file.

    另外我之前附上的代码是MSP432P401R系列的例程

  • 你好,我虽然使用了循环打开PWM,但是我并没有使用同样的index,而是利用了循环变量i“PWM_open(i,params+i)”

    此外,MSP432P4和E4型号名字相似,但是PWM实现外设不同,差别较大,还麻烦您帮我再问一问,以解我心头之困,谢谢

  • 谢谢您的反馈,我之后会咨询下同事后给您回复