Я хочу расширить свой таймер для подсчета тиков больше, чем 65536, что составляет 2 ^ 16 в 16-битном режиме в таймере A или B. И я знаю, что эта проблема решается путем объединения как timerA, так и timerB.
void PWM_vInit( void ){
/* 1- Enable and provide a clock to 16/32-bit general-purpose timer
module 0 in Run mode and enable and provide a clock
to GPIO Port F in Run mode */
setBit( RCGCGPIO, R5 );
setBit( RCGCTIMER, R0 ); /* Activate Timer0 */
/* 2- Ensure the timer is disabled before making any changes */
clearBit( GPTMCTL, TAEN );
clearBit( GPTMCTL, TBEN );
/* 3- Enable 32-bit timer0 -> 0x0 */
clearBit( GPTMCFG, 2 );
/* 4- Configure both TAMR and TBMR fields in both GPTMTAMR and
GPTMTBMR in PWM mode. */
setBit( GPTMTAMR, TAAMS ); /* PWM */
clearBit( GPTMTAMR, TACMR ); /* Edge count */
setBit( GPTMTAMR, 1 ); /* Periodic */
clearBit( GPTMTAMR, 0 );
setBit( GPTMTBMR, TBAMS ); /* PWM */
clearBit( GPTMTBMR, TBCMR ); /* Edge count */
setBit( GPTMTBMR, 1 ); /* Periodic */
clearBit( GPTMTBMR, 0 );
/* 5- Configure the O/P state of the PWM signal in the TPWML field
of the (GPTMCTL) register -> output is unaffected ( non-inverted ) */
clearBit( GPTMCTL, TAPWML);
clearBit( GPTMCTL, TBPWML);
/* 6- If a prescaler is to be used, write the prescale value to the
GPTM Timer B Prescale Register (GPTMTBPR) */
/* 7- */
/* 10- Change the function of PF1 pin rather than GPIO */
setBit( GPIOAFSEL_PORTF, PF1 );
/* 11- Enabling PF1 to be PWM generator */
clearBit( GPIOPCTL_PORTF, PMC1_PORTF_PIN3 );
setBit( GPIOPCTL_PORTF, PMC1_PORTF_PIN2 );
setBit( GPIOPCTL_PORTF, PMC1_PORTF_PIN1 );
setBit( GPIOPCTL_PORTF, PMC1_PORTF_PIN0 );
setBit( GPIODEN_PORTF, PORTF_DEN_PIN1 );
/* 12- Enable both timerA and timerB to start counting */
setBit( GPTMCTL, TAEN );
setBit( GPTMCTL, TBEN );
}
void PWM_vPulsating( INT32U u32InitialValue, INT32U u32CompareMatchValue )
{
/* 1- Load the timer start value into the GPTM Timer B Interval
Load (GPTMTBILR) register */
GPTMTAILR = u32InitialValue;
GPTMTBILR = ( u32InitialValue << 16 );
/* 2- Load the GPTM TimerB Match (GPTMTBMATCHR) register with the
match value */
GPTMTAMATCHR = u32CompareMatchValue;
GPTMTBMATCHR = ( u32CompareMatchValue << 16 );
}
Теперь я должен ожидать, что при передаче аргументов в «PWM_vPulsating», обратите внимание, что оба значения больше 65536, драйвер работает, и я получаю ШИМ на своем осциллографе!Но, к сожалению, ничего не работает.