Thread 中讨论的其他器件:EK-TM4C1294XL
您好!
我正在使用 TM4C129XNZAD 微控制器、我想使用计时器概念应用一秒延迟、您能告诉我如何实施代码、还是与计时器共享样本代码一秒延迟。
谢谢、请就此为我提供帮助、我正在等待您的回复。
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.
您好!
我正在使用 TM4C129XNZAD 微控制器、我想使用计时器概念应用一秒延迟、您能告诉我如何实施代码、还是与计时器共享样本代码一秒延迟。
谢谢、请就此为我提供帮助、我正在等待您的回复。
您好!
有一个相关示例。 请参阅:
C:\ti\TivaWare_C_Series-2.2.0.295\examples\peripherals\timer\OneShot_16bit.c \\ 此示例展示了如何将 Timer0B 配置为单次触发计时器、并在1ms 后触发单次中断。
C:\ti\TivaWare_C_Series-2.2.0.295\examples\peripheral\timer\period_16bit.c \\ 此示例展示了如何将 Timer0B 配置为周期性计时器、每1ms 触发一次中断。
另一个定时器示例可在 C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c1294xl\timers 中找到。
您好!
您是否了解 了我在上次答复中列出的示例 C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c1294xl\timers? 它正按照您的需要进行操作-生成1秒的延迟。 为什么不通过代码来查看两个计时器如何配置为生成1秒半的中断。 下面是代码片段。
//
// Enable the GPIO port that is used for the on-board LEDs.
//
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
//
// Enable the GPIO pins for the LEDs (PN0 & PN1).
//
MAP_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0 | GPIO_PIN_1);
//
// Enable the peripherals used by this example.
//
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
//
// Enable processor interrupts.
//
MAP_IntMasterEnable();
//
// Configure the two 32-bit periodic timers.
//
MAP_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
MAP_TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC);
MAP_TimerLoadSet(TIMER0_BASE, TIMER_A, g_ui32SysClock);
MAP_TimerLoadSet(TIMER1_BASE, TIMER_A, g_ui32SysClock / 2);
//
// Setup the interrupts for the timer timeouts.
//
MAP_IntEnable(INT_TIMER0A);
MAP_IntEnable(INT_TIMER1A);
MAP_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
MAP_TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
//
// Enable the timers.
//
MAP_TimerEnable(TIMER0_BASE, TIMER_A);
MAP_TimerEnable(TIMER1_BASE, TIMER_A);