MSP432P401R的TA1.0或TA2.0之类的引脚如何配置PWM引脚操作舵机的机械臂,可以使用PWM功能的引脚及占用情况如下,想问一下YTA0.0、TA1.0的引脚可以操作PWM舵机吗?如何配置,没有多余的引脚了,需要3路PWM,端口映射也找不到合适的。
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.
MSP432P401R的TA1.0或TA2.0之类的引脚如何配置PWM引脚操作舵机的机械臂,可以使用PWM功能的引脚及占用情况如下,想问一下YTA0.0、TA1.0的引脚可以操作PWM舵机吗?如何配置,没有多余的引脚了,需要3路PWM,端口映射也找不到合适的。
相关例程您可以参考
http://dev.ti.com/tirex/explore/node?node=APAOZq40W2CyGVgJMMsEMA__z-lQYNj__LATEST
/* --COPYRIGHT--,BSD
* Copyright (c) 2017, 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,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --/COPYRIGHT--*/
/*******************************************************************************
* MSP432 Port Mapper - Remapping Timer_A CCR
*
* Description: This program generates a PWM output on P2.4 using the port
* mapper to internally redirect the CCR0 output of Timer A1 to P2.4 (it
* is originally P7.7). After the port mapping function is called, the timer
* is setup normally with a 75% duty cycle. The output of the timer can be
* seen on P2.4 using a probe/debugger.
*
* MSP432P401
* -------------------
* /|\| |
* | | |
* --|RST |
* | |
* | P2.4 |--> CCR1 - 75% PWM
* | |
*
*******************************************************************************/
/* DriverLib Includes */
#include <ti/devices/msp432p4xx/driverlib/driverlib.h>
/* Standard Includes */
#include <stdint.h>
#include <stdbool.h>
//![Simple PMAP Config]
/* Port mapper configuration register */
const uint8_t port_mapping[] =
{
//Port P2:
PMAP_NONE, PMAP_NONE, PMAP_NONE, PMAP_NONE, PMAP_TA1CCR1A, PMAP_NONE,
PMAP_NONE, PMAP_NONE
};
//![Simple PMAP Config]
/* Timer_A UpDown Configuration Parameter */
const Timer_A_UpDownModeConfig upDownConfig =
{
TIMER_A_CLOCKSOURCE_SMCLK, // SMCLK Clock SOurce
TIMER_A_CLOCKSOURCE_DIVIDER_1, // SMCLK/1 = 3MHz
127, // 127 tick period
TIMER_A_TAIE_INTERRUPT_DISABLE, // Disable Timer interrupt
TIMER_A_CCIE_CCR0_INTERRUPT_DISABLE, // Disable CCR0 interrupt
TIMER_A_DO_CLEAR // Clear value
};
/* Timer_A Compare Configuration Parameter (PWM1) */
const Timer_A_CompareModeConfig compareConfig_PWM1 =
{
TIMER_A_CAPTURECOMPARE_REGISTER_1, // Use CCR1
TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE, // Disable CCR interrupt
TIMER_A_OUTPUTMODE_TOGGLE_SET, // Toggle output but
32 // 32 Duty Cycle
};
int main(void)
{
MAP_WDT_A_holdTimer();
//![Simple PMAP Example]
/* Remapping TACCR0 to P2.4 */
MAP_PMAP_configurePorts((const uint8_t *) port_mapping, PMAP_P2MAP, 1,
PMAP_DISABLE_RECONFIGURATION);
//![Simple PMAP Example]
MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2,
GPIO_PIN4, GPIO_PRIMARY_MODULE_FUNCTION);
/* Initialize compare registers to generate PWM1 */
MAP_Timer_A_initCompare(TIMER_A1_BASE, &compareConfig_PWM1);
/* Configuring Timer_A1 for UpDown Mode and starting */
MAP_Timer_A_configureUpDownMode(TIMER_A1_BASE, &upDownConfig);
MAP_Timer_A_startCounter(TIMER_A1_BASE, TIMER_A_UPDOWN_MODE);
while (1)
{
MAP_PCM_gotoLPM0();
}
}