BF609开发板,A17插座把 PE14管脚引出了,这个脚作为定时器TMR0的输出管脚,我程序把定时器设置为PWM_OUT工作模式,开启了管脚复用功能,但是用示波器没有在这个管脚看到 波形输出,为什么呢?
定时器配置代码是官方发布的代码:
/*******************************************************************
* Function: Init_Timers
* Description: This function initializes Timer0 for PWM mode.
*******************************************************************/
void Init_Timers(void)
{
/* active state, auto reload, generate no interrupt */
*pTCNTL = BITM_TCNTL_PWR | BITM_TCNTL_AUTORLD | BITM_TCNTL_INT ;
*pTPERIOD = TIMEOUT_PERIOD;
*pTSCALE = TIMEOUT_PERIOD/2;
/* enable the timer */
*pTCNTL |= BITM_TCNTL_EN;
}
/*******************************************************************
* Function: Init_Timer_Interrupts
* Description: This function initializes the interrupts for Timer0
*******************************************************************/
void Init_Timer_Interrupts(void)
{
ADI_TMR_RESULT eTmrResult = ADI_TMR_SUCCESS;
if(!ghTimer)
{
/* Open the timer */
if( (eTmrResult = adi_tmr_Open (
TEST_TIMER_NUM,
TimerMemory,
ADI_TMR_MEMORY,
TimerHandler,
NULL,
&ghTimer)) != ADI_TMR_SUCCESS)
{
DEBUG_PRINT("Timer open failed 0x%08X \n", eTmrResult);
}
/* Set the mode to PWM OUT */
if((eTmrResult = adi_tmr_SetMode(
ghTimer,
ADI_TMR_MODE_CONTINUOUS_PWMOUT)) != ADI_TMR_SUCCESS)
{
DEBUG_PRINT("Failed to open timer in PWM out mode 0x%08X \n", eTmrResult);
}
/* Set the IRQ mode to get interrupt after timer counts to Delay + Width */
if((eTmrResult = adi_tmr_SetIRQMode(
ghTimer,
ADI_TMR_IRQMODE_WIDTH_DELAY)) != ADI_TMR_SUCCESS)
{
DEBUG_PRINT("Failed to set the timer IRQ mode 0x%08X \n", eTmrResult);
}
/* Set the Period */
if((eTmrResult = adi_tmr_SetPeriod(
ghTimer,
TIMER_PERIOD)) != ADI_TMR_SUCCESS)
{
DEBUG_PRINT("Failed to set the timer Period 0x%08X \n", eTmrResult);
}
/* Set the timer width */
if((eTmrResult = adi_tmr_SetWidth(
ghTimer,
TIMER_WIDTH)) != ADI_TMR_SUCCESS)
{
DEBUG_PRINT("Failed to set the timer Width 0x%08X \n", eTmrResult);
}
/* Set the timer Delay */
if((eTmrResult = adi_tmr_SetDelay(
ghTimer,
TIMER_DELAY)) != ADI_TMR_SUCCESS)
{
DEBUG_PRINT("Failed to set the timer Delay 0x%08X \n", eTmrResult);
}
/* Enable the timer to stop gracefully */
if((eTmrResult = adi_tmr_EnableGracefulStop(
ghTimer,
true)) != ADI_TMR_SUCCESS)
{
DEBUG_PRINT("Failed to enable the timer to stop gracefully 0x%08X \n", eTmrResult);
}
}
/* Enable the timer*/
if((eTmrResult = adi_tmr_Enable(
ghTimer,
true)) != ADI_TMR_SUCCESS)
{
DEBUG_PRINT("Failed to enable the timer 0x%08X \n", eTmrResult);
}
}
「该帖子被 kladsp 在 2015-03-12 15:13:56 编辑过」