Arm Tiva-C边缘定时模式

Arm Tiva-C边缘定时模式,arm,microcontroller,Arm,Microcontroller,您好,我最近一直在使用Tm4c123gh6pm进行编码,我遇到了一个部分,我想使用边缘计时模式,现在我没有使用tivaware api,我只是使用传统的寄存器级别并遵循数据表,我遇到了这个问题 我想知道哪个管脚用来作为计时器等待上升沿出现的管脚,以便它移动当前的计时器值? 我查看了数据表,我能找到的是计时器0与PB6和PF0有某种联系,现在我尝试了PB6,但它不起作用,但这是正确的方法吗? 微控制器定时器等待上升沿移动当前定时器值时,这些引脚是否正确? 这是我的代码示例,请注意,这只是一个测试代

您好,我最近一直在使用Tm4c123gh6pm进行编码,我遇到了一个部分,我想使用边缘计时模式,现在我没有使用tivaware api,我只是使用传统的寄存器级别并遵循数据表,我遇到了这个问题 我想知道哪个管脚用来作为计时器等待上升沿出现的管脚,以便它移动当前的计时器值? 我查看了数据表,我能找到的是计时器0与PB6和PF0有某种联系,现在我尝试了PB6,但它不起作用,但这是正确的方法吗? 微控制器定时器等待上升沿移动当前定时器值时,这些引脚是否正确? 这是我的代码示例,请注意,这只是一个测试代码,我正在尝试它不是最终代码。我所做的是复制数据表中的初始化部分,以达到我想要的计时器模式,然后一步一步地执行 此代码将使计数器从0xFF开始向下运行,但当我在PB6上放置“高”信号(即3.3伏)时,没有任何内容移动到GPTMTnR寄存器。 我只是想知道是不是有什么我做错了而我没有注意到

   #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.*/
}
#包括“tm4c123gh6pm.h”
void Timer0Init(void);
内部主(空)
{
int i=0;
Timer0Init();
而(1){

对于(i=0;i我的portb初始化有问题,我在该部分使用tivaware,它现在工作得非常好,将PB6置于高位,它将当前计时器值传递到另一个寄存器 还要注意的是,当向上计数时,计时器向上计数到TAIL\u R寄存器中初始化的值,如果您想重置计时器,则需要将您希望计时器开始的值写入TAV\u R寄存器中 祝大家好运