Привет, я недавно занимался кодированием Tm4c123gh6pm, и я столкнулся с той частью, где я хочу использовать режим хронологического режима, теперь я не пошел на tivaware api, я просто пошел на традиционный уровень регистрации и после таблицы данных, и я столкнулся с этой проблемой Я хочу знать, какой контакт использовать, как тот, где таймер ждет, чтобы нарастающий фронт пришел, чтобы он перемещал текущее значение таймера? Я проверил лист данных, все, что я могу найти, это то, что таймер 0 каким-то образом связан с PB6 и PF0, теперь я попытался использовать PB6, и это не сработало, но это даже правильный подход? - это правильные контакты, таймер микроконтроллера ждет, когда передний фронт переместит текущее значение таймера? вот пример моего кода и, пожалуйста, обратите внимание, что это всего лишь тестовый код, который я пытаюсь сделать не окончательным кодом, что я сделал, это скопировать раздел инициализации в таблицу данных для режима таймера, который я хочу, и следовать ему шаг за шагом это код будет запускать счетчик с 0xFF вниз, но когда я поставлю «высокий» сигнал, т.е. 3,3 вольта на PB6, ничего не будет перемещено в регистр GPTMTnR. Мне просто интересно, есть ли что-то, что я делаю неправильно, и я не замечаю?Tiva C edge timing mode
#include "tm4c123gh6pm.h"
void Timer0Init(void);
int main(void)
{
int i=0;
Timer0Init();
while(1){
for(i=0;i<100000;i++){
}
}
return 0;
}
void Timer0Init(void)
{
//initialize PORT B
volatile unsigned long delay;
SYSCTL_RCGC2_R |= 0x00000002; // 1) B clock
delay = SYSCTL_RCGC2_R; // delay to allow clock to stabilize
GPIO_PORTB_AMSEL_R &= 0x00; // 2) disable analog function
GPIO_PORTB_PCTL_R &= 0x00000000; // 3) GPIO clear bit PCTL
GPIO_PORTB_DIR_R &= 0x00; // 4.2) PB all input
GPIO_PORTB_AFSEL_R &= 0x40; // 5) no alternate function
GPIO_PORTB_DEN_R |= 0xFF; // 7) enable digital pins PF4-PF1
GPIO_PORTB_PCTL_R = 7;
//timer clock
SYSCTL_RCGCTIMER_R |=0x01;
delay = SYSCTL_RCGCTIMER_R;
//1. Ensure the timer is disabled (the TnEN bit is cleared) before making any changes.
TIMER0_CTL_R &= 0xFE;
//2. Write the GPTM Configuration (GPTMCFG) register with a value of 0x0000.0004.
TIMER0_CFG_R= 0x00000004;
//3. In the GPTM Timer Mode (GPTMTnMR) register, write the TnCMR field to 0x1 and the TnMR field to 0x3.
TIMER0_TAMR_R= TIMER0_TAMR_R | 0x007;
//4. Configure the type of event that the timer captures by writing the TnEVENT field of the GPTM Control (GPTMCTL) register.
TIMER0_CTL_R = TIMER0_CTL_R & 0xFFFFFFF3;
//5. If a prescaler is to be used, write the prescale value to the GPTM Timer n Prescale Register (GPTMTnPR).
//no prescaler for now
//6. Load the timer start value into the GPTM Timer n Interval Load (GPTMTnILR) register.
TIMER0_TAILR_R = 0xFF;
//7. If interrupts are required, set the CnEIM bit in the GPTM Interrupt Mask (GPTMIMR) register.
//no interrupts required
//8. Set the TnEN bit in the GPTM Control (GPTMCTL) register to enable the timer and start counting.
TIMER0_CTL_R= TIMER0_CTL_R & 0x00000001;
TIMER0_CTL_R |= 0x01;
//9. Poll the CnERIS bit in the GPTMRIS register or wait for the interrupt to be generated (if enabled). In both cases,
//the status flags are cleared by writing a 1 to the CnECINT bit of the GPTM Interrupt Clear (GPTMICR) register.
//The time at which the event happened can be obtained by reading the GPTM Timer n (GPTMTnR) register.
/*In Input Edge Timing mode, the timer continues running after an edge event has been detected,
but the timer interval can be changed at any time by writing the GPTMTnILR register. The change
takes effect at the next cycle after the write.*/
}