劳烦大家了
不知道大家有没有遇到这个问题,我在测试MSP432开发板的时候发现,在LFAM模式下,采用REFO128KHz作为时钟源。
第一种模式:采用Timer32作为计时器,每到一个中断启动TimerA,利用PWM函数产生方波;两个方波的频率不同;
第二种模式:采用Timer32_1作为主计时器,每到一个中断启动Timer32_2,其周期较小,不断触发端口,产生方波,也是产生两种不同频率的方波;
问题是:这两种方波都在开始阶段会有一个不符合的较大间隔。
各位大牛,这个间隔是因为中断中处理程序导致的吗?还有有没有办法去掉这个间隔吗?
Susan Yang:
请问您MSP432开发板的具体型号是怎样的?
程序部分呢?是使用TI的例程还是您自己的程序?具体实验步骤是怎样的?
若是可以的话,请贴出或者私信我程序,谢谢
user6204443:
回复 Susan Yang:
用的是MSP432P401R LaunchPad-Red 2.0
Timer_A_PWMConfig pwmConfig0 = {TIMER_A_CLOCKSOURCE_SMCLK,TIMER_A_CLOCKSOURCE_DIVIDER_1,64,TIMER_A_CAPTURECOMPARE_REGISTER_1,TIMER_A_OUTPUTMODE_RESET_SET,32 };bool OZFlag = true;Timer_A_PWMConfig pwmConfig1 = {TIMER_A_CLOCKSOURCE_SMCLK,TIMER_A_CLOCKSOURCE_DIVIDER_1,64,TIMER_A_CAPTURECOMPARE_REGISTER_1,TIMER_A_OUTPUTMODE_RESET_SET,32 }; //![Simple Timer_A Config]Timer_A_PWMConfig pwmConfig1 = {TIMER_A_CLOCKSOURCE_SMCLK,TIMER_A_CLOCKSOURCE_DIVIDER_1,98,TIMER_A_CAPTURECOMPARE_REGISTER_1,TIMER_A_OUTPUTMODE_RESET_SET,49 };int main(void) {/* Halting the watchdog */MAP_WDT_A_holdTimer();//![Simple Timer_A Example]/* Setting MCLK to REFO at 128Khz for LF mode* Setting SMCLK to 64Khz */MAP_CS_setReferenceOscillatorFrequency(CS_REFO_128KHZ);MAP_CS_initClockSignal(CS_MCLK, CS_REFOCLK_SELECT, CS_CLOCK_DIVIDER_1);MAP_CS_initClockSignal(CS_SMCLK, CS_REFOCLK_SELECT, CS_CLOCK_DIVIDER_1);MAP_CS_initClockSignal(CS_HSMCLK, CS_REFOCLK_SELECT, CS_CLOCK_DIVIDER_1);MAP_PCM_setPowerState(PCM_AM_LF_VCORE0);/* Configuring GPIO2.4 as peripheral output for PWM */MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2, GPIO_PIN4,GPIO_PRIMARY_MODULE_FUNCTION);TIMER32_1->CONTROL = TIMER32_CONTROL_SIZE | TIMER32_CONTROL_MODE;// Load Timer32 Counter with initial valueTIMER32_1->LOAD= 512;// Enalbe the Timer32 interrupt in NVIC__enable_irq();NVIC->ISER[0] = 1 << ((T32_INT1_IRQn) & 31);// Start Timer32 and enable interruptTIMER32_1->CONTROL |= TIMER32_CONTROL_ENABLE |TIMER32_CONTROL_IE;// Disable sleep on exit from ISRSCB->SCR &= ~SCB_SCR_SLEEPONEXIT_Msk;// Ensures SLEEPONEXIT takes effect immediately__DSB();// Enter LPM0 and wait for the timer interrupt to wake-up__sleep();__no_operation();} void T32_INT1_IRQHandler(void) {TIMER32_1->INTCLR |= BIT0;if(OZFlag){MAP_Timer_A_generatePWM(TIMER_A0_BASE, &pwmConfig1);OZFlag = false;}else{MAP_Timer_A_generatePWM(TIMER_A0_BASE, &pwmConfig0);OZFlag = true;} }
Susan Yang:
回复 user6204443:
很抱歉,我测试了一下,并没有捕捉到“这两种方波都在开始阶段会有一个不符合的较大间隔”
请问您能否贴上波形图?
是类似下面帖子这样的?
e2e.ti.com/…/774035
user6204443:
回复 Susan Yang:
这部分是由于判断语句,活着pwm产生函数调用产生的延迟吗?麻烦您了~