Part Number: MSP432P401R
Tool/software: Code Composer Studio
Hi i am trying to get the external clock for the timer but it is not working.
/* DriverLib Includes */
#include <ti/devices/msp432p4xx/driverlib/driverlib.h>
/* Application Defines */
#define TIMER_PERIOD 6//127
#define TIMER_PERIOD_GATE 96
#define DUTY_CYCLE1 3//32
#define DUTY_CYCLE2 2//96
/* 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
TIMER_PERIOD, // 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
DUTY_CYCLE1 // 32 Duty Cycle
};
/* Timer_A UpDown Configuration Parameter */
const Timer_A_UpDownModeConfig upDownConfig1 =
{
TIMER_A_CLOCKSOURCE_EXTERNAL_TXCLK, // SMCLK Clock SOurce //TIMER_A_CLOCKSOURCE_EXTERNAL_TXCLK TIMER_A_CLOCKSOURCE_SMCLK
TIMER_A_CLOCKSOURCE_DIVIDER_1, // SMCLK/1 = 3MHz
2,//TIMER_PERIOD_GATE, // 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 (PWM2) */
const Timer_A_CompareModeConfig compareConfig_PWM2 =
{
TIMER_A_CAPTURECOMPARE_REGISTER_1, // Use CCR2
TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE, // Disable CCR interrupt
TIMER_A_OUTPUTMODE_TOGGLE_SET, // Toggle output but
1//TIMER_PERIOD_GATE*0.75 // Duty Cycle
};
int main(void)
{
/* Stop WDT */
MAP_WDT_A_holdTimer();
GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_PJ, GPIO_PIN2 | GPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION);
CS_setExternalClockSourceFrequency(32768,48000000);
PCM_setCoreVoltageLevel(PCM_VCORE1);
FlashCtl_setWaitState(FLASH_BANK0, 2);
FlashCtl_setWaitState(FLASH_BANK1, 2);
CS_startHFXT(false);
CS_initClockSignal(CS_MCLK , CS_HFXTCLK_SELECT, CS_CLOCK_DIVIDER_1);
CS_initClockSignal(CS_SMCLK, CS_HFXTCLK_SELECT, CS_CLOCK_DIVIDER_1);// MHz
/* Setting P7.7 and P7.6 and peripheral outputs for CCR */
MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P7, GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION);
MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2, GPIO_PIN4, GPIO_PRIMARY_MODULE_FUNCTION);
MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P7, GPIO_PIN2, GPIO_PRIMARY_MODULE_FUNCTION);
/* 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);
MAP_Timer_A_configureUpDownMode(TIMER_A0_BASE, &upDownConfig1);
MAP_Timer_A_startCounter(TIMER_A0_BASE, TIMER_A_UPDOWN_MODE);
/* Initialize compare registers to generate PWM2 */
MAP_Timer_A_initCompare(TIMER_A0_BASE, &compareConfig_PWM2);
/* Initialize compare registers to generate PWM1 */
MAP_Timer_A_initCompare(TIMER_A1_BASE, &compareConfig_PWM1);
/* Sleeping when not in use */
while (1)
{
MAP_PCM_gotoLPM0();
}
}
So one timer ismaking a 4MHz clock and i rewire the GPIO7.7 to GPIO7.2 so that the second timer uses the external 4MHz clock for counting up.
Once counting, the second timer should output in GPIO2.4 but the signal is not appearing.
Maybe the initialization is wrong?(MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P7, GPIO_PIN2, GPIO_PRIMARY_MODULE_FUNCTION);)