This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] TM4C1294KCPDT:CCP 模块使能- TM4C1294KCPDT -示例代码

Guru**** 2528390 points
Other Parts Discussed in Thread: TM4C1294KCPDT

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1045329/tm4c1294kcpdt-ccp-module-enable--tm4c1294kcpdt--example-code

器件型号:TM4C1294KCPDT

您好!

 我正在使用 TM4C1294KCPDT 控制器库板。 我需要将 PL1引脚启用为 CCP 引脚。 对于 RPM 测量 ,我需要使用 CCP 模块来捕获两个连续乘法之间的时间。 您能否与 TM4C1294KCPDT 的 CCP 模块启用示例代码共享。

浏览 CCP 模具示例我有 Keil 示例代码。 请共享 CCS IDE 的 ME 代码。

谢谢、此致、

Rani

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我在 Keil IDE 中尝试了以下代码。请在   CCS IDE 中共享同一个的 ME 配置。

    #include "TM4C123GH6PM.h"
    #include <stdio.h>
    
    
    /*Function prototype for Timer0A and UART module initialization */
    void timer1A_delaySec(int ttime);
    int Timer3A_countCapture(void);
    void Timer3ACounter_init(void);
    void UART5_init(void);
    void UART5_Transmitter(unsigned char data);
    void printstring(char *str);
    
    /* global variables to store and display pulse width or duration */
    unsigned int counter;
    char mesg[12];
    
    /* main code to take RPM measurements and send data to UART terminal */
    
    int main(void)
    {
       Timer3ACounter_init(); 
       UART5_init();
      while(1)
    	{
          TIMER3->CTL |= 1;   /* enable timer3A */
          timer1A_delaySec(1);
          counter = Timer3A_countCapture();
          TIMER3->CTL &= ~1; /* disable TIMER3A during setup */
          TIMER3->TAV = 0;
          TIMER3->TAR = 0;
          sprintf(mesg, "\r\nRPM = %d RPM", counter*60); /* convert float to string */
          printstring(mesg); /* print frequency on serial monitor*/
    	}
    	
    }
    
    /* Configure Timer3A in input-edge counter mode */
    void Timer3ACounter_init(void)
    {
    SYSCTL->RCGCTIMER |= (1<<3);  /* enable clock to Timer Block 3  */
    SYSCTL->RCGCGPIO |= (1<<1);      /* enable clock to PORTB  */
    
    GPIOB->DIR &= ~(1<<2);        /* make PB2 an input pin */
    GPIOB->DEN |= (1<<2);         /* make PB2 a digital pin */
    GPIOB->AFSEL |= (1<<2);       /* enable alternate function on PB2 */
    GPIOB->PCTL &= ~0x00000F00;  /* configure PB2 as T3CCP0 pin */
    GPIOB->PCTL |= 0x00000700;
        
    TIMER3->CTL &= ~(1<<0);  /* disable TIMER3A during setup */
    TIMER3->CFG |= (1<<2);  /* configure as 16-bit timer mode */
    TIMER3->TAMR = 0x13;        /* up-count, edge-count, capture mode */
    TIMER3->TAMATCHR = 0xFFFF;  /* set the count limit */
    TIMER3->TAPMR = 0xFF;	      /* to 0xFFFFFF with prescaler */
    TIMER3->CTL |= ~(1<<3)|~(1<<2); /* capture the rising edge */
    }
    
    /* this routine will execute after every one second */
    
    int Timer3A_countCapture(void)
    {
        return TIMER3->TAR;
    }
    
    
    /* Create one second delay using Timer block 1 and sub timer A */
    
    void timer1A_delaySec(int ttime)
    {
        int i;
        SYSCTL->RCGCTIMER |= 2;     /* enable clock to Timer Block 1 */
        
    TIMER1->CTL = 0;            /* disable Timer before initialization */
        TIMER1->CFG = 0x04;         /* 16-bit option */ 
        TIMER1->TAMR = 0x02;        /* periodic mode and down-counter */
        TIMER1->TAILR = 64000 - 1;  /* TimerA interval load value reg */
        TIMER1->TAPR = 250 - 1;     /* TimerA Prescaler 16MHz/250=64000Hz */
        TIMER1->ICR = 0x1;          /* clear the TimerA timeout flag */
        TIMER1->CTL |= 0x01;        /* enable Timer A after initialization */
    
        for(i = 0; i < ttime; i++)
        {
            while ((TIMER1->RIS & 0x1) == 0) ;      /* wait for TimerA timeout flag */
            TIMER1->ICR = 0x1;      /* clear the TimerA timeout flag */
        }
    }
    void UART5_init(void)
    {
        SYSCTL->RCGCUART |= 0x20;  /* enable clock to UART5 */
        SYSCTL->RCGCGPIO |= 0x10;  /* enable clock to PORTE for PE4/Rx and RE5/Tx */
        /* UART0 initialization */
        UART5->CTL = 0;         /* UART5 module disbable */
        UART5->IBRD = 104;      /* for 9600 baud rate, integer = 104 */
        UART5->FBRD = 11;       /* for 9600 baud rate, fractional = 11*/
        UART5->CC = 0;          /*select system clock*/
        UART5->LCRH = 0x60;     /* data lenght 8-bit, not parity bit, no FIFO */
        UART5->CTL = 0x301;     /* Enable UART5 module, Rx and Tx */
    
        /* UART5 TX5 and RX5 use PE4 and PE5. Configure them digital and enable alternate function */
        GPIOE->DEN = 0x30;      /* set PE4 and PE5 as digital */
        GPIOE->AFSEL = 0x30;    /* Use PE4,PE5 alternate function */
        GPIOE->AMSEL = 0;    /* Turn off analg function*/
        GPIOE->PCTL = 0x00110000;     /* configure PE4 and PE5 for UART */
    }
    void UART5_Transmitter(unsigned char data)  
    {
        while((UART5->FR & (1<<5)) != 0); /* wait until Tx buffer not full */
        UART5->DR = data;                  /* before giving it another byte */
    }
    
    void printstring(char *str)
    {
      while(*str)
    	{
    		UART5_Transmitter(*(str++));
    	}
    }
    
    /* This function is called by the startup assembly code to perform system specific initialization tasks. */
    void SystemInit(void)
    {
        SCB->CPACR |= 0x00F00000;
    }
     

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好 Sankareswaran、

    也许下面的链接可以帮助实现 RPM 计数、而不是简单的 CCP 任务、如果 PWM 也将控制风扇速度。 我们不建议在代码中直接加载 BTW 寄存器、本论坛不容易提供支持。

    发生 GPTM 定时器边沿捕获计数的不稳定低频中断。 -基于 Arm 的微控制器论坛-基于 Arm 的微控制器- TI E2E 支持论坛

    此致、

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好 Rani、

    我一直在努力为此准备一个 TivaWare 示例、但我尚未使其完全正常工作、因此我将尝试在明天下午完成并将其发布在这里。

    此致、

    Ralph Jacobi

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好 Rani、

    下面是完整的 TivaWare 示例、您 可以参考如何设置用于 CCP 监控的定时器来跟踪两个上升沿之间的时间。

    e2e.ti.com/.../edge_5F00_time.zip

    此致、

    Ralph Jacobi

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Ralph Jacobi、

       我已导入代码 ,当 我生成代码时出现以下错误。 在这里我可以找到这两个文件  “inc/hw_ints.h,inc/hw_NVIC.h”。

    谢谢、此致、

    Rani  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好 Rani、

    如果您没有安装 TivaWare 2.2.0、我建议 您下载并安装它 、否则您可能会遇到更多构建错误。 如果在 c:\ti 之外安装、则只需在"Resource"->"Linked Resources"下的 CCS 工程设置中更新 SW_ROOT 的路径

    这两个文件都来自 TivaWare、位于 :[INSTALL Path]\TivaWare_C_Series-2.2.0.295\inc

    此致、

    Ralph Jacobi