完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
定时器1,2 分别与INT13、INT14关联以后,怎么才能时能这些中断?在哪里进行设置?如何设置?
|
|
相关推荐
5 个讨论
|
|
过路人_1024 发表于 2018-12-13 20:11 楼主如果要操作CPUTimer0,1,2,可以参考下面这个历程,用到了0,1,2 都有ISR: //########################################################################### // Description: //! addtogroup f2803x_example_list //! Cpu Timer (cpu_timer)//! //! This example configures CPU Timer0, 1, and 2 and increments //! a counter each time the timer asserts an interrupt. //! //! b Watch b Variables n //! - CpuTimer0.InterruptCount //! - CpuTimer1.InterruptCount //! - CpuTimer2.InterruptCount // //########################################################################### // $TI Release: F2803x C/C++ Header Files and Peripheral Examples V126 $ // $Release Date: November 30, 2011 $ //########################################################################### #include "DSP28x_Project.h" // Device Headerfile and Examples Include File // Prototype statements for functions found within this file. __interrupt void cpu_timer0_isr(void); __interrupt void cpu_timer1_isr(void); __interrupt void cpu_timer2_isr(void); void main(void) [ // Step 1. Initialize System Control: // PLL, WatchDog, enable Peripheral Clocks // This example function is found in the DSP2803x_SysCtrl.c file. InitSysCtrl(); // Step 2. Initalize GPIO: // This example function is found in the DSP2803x_Gpio.c file and // illustrates how to set the GPIO to it's default state. // InitGpio(); // Skipped for this example // Step 3. Clear all interrupts and initialize PIE vector table: // Disable CPU interrupts DINT; // Initialize the PIE control registers to their default state. // The default state is all PIE interrupts disabled and flags // are cleared. // This function is found in the DSP2803x_PieCtrl.c file. InitPieCtrl(); // Disable CPU interrupts and clear all CPU interrupt flags: IER = 0x0000; IFR = 0x0000; // Initialize the PIE vector table with pointers to the shell Interrupt // Service Routines (ISR). // This will populate the entire table, even if the interrupt // is not used in this example. This is useful for debug purposes. // The shell ISR routines are found in DSP2803x_DefaultIsr.c. // This function is found in DSP2803x_PieVect.c. InitPieVectTable(); // Interrupts that are used in this example are re-mapped to // ISR functions found within this file. EALLOW; // This is needed to write to EALLOW protected registers PieVectTable.TINT0 = &cpu_timer0_isr; PieVectTable.TINT1 = &cpu_timer1_isr; PieVectTable.TINT2 = &cpu_timer2_isr; EDIS; // This is needed to disable write to EALLOW protected registers // Step 4. Initialize the Device Peripheral. This function can be // found in DSP2803x_CpuTimers.c InitCpuTimers(); // For this example, only initialize the Cpu Timers // Configure CPU-Timer 0, 1, and 2 to interrupt every second: // 60MHz CPU Freq, 1 second Period (in uSeconds) ConfigCpuTimer(&CpuTimer0, 60, 1000000); ConfigCpuTimer(&CpuTimer1, 60, 1000000); ConfigCpuTimer(&CpuTimer2, 60, 1000000); // To ensure precise timing, use write-only instructions to write to the entire register. Therefore, if any // of the configuration bits are changed in ConfigCpuTimer and InitCpuTimers (in DSP2803x_CpuTimers.h), the // below settings must also be updated. CpuTimer0Regs.TCR.all = 0x4000; // Use write-only instruction to set TSS bit = 0 CpuTimer1Regs.TCR.all = 0x4000; // Use write-only instruction to set TSS bit = 0 CpuTimer2Regs.TCR.all = 0x4000; // Use write-only instruction to set TSS bit = 0 // Step 5. User specific code, enable interrupts: // Enable CPU int1 which is connected to CPU-Timer 0, CPU int13 // which is connected to CPU-Timer 1, and CPU int 14, which is connected // to CPU-Timer 2: IER |= M_INT1; IER |= M_INT13; IER |= M_INT14; // Enable TINT0 in the PIE: Group 1 interrupt 7 PieCtrlRegs.PIEIER1.bit.INTx7 = 1; // Enable global Interrupts and higher priority real-time debug events: EINT; // Enable Global interrupt INTM ERTM; // Enable Global realtime interrupt DBGM // Step 6. IDLE loop. Just sit and loop forever (optional): for(;;); ] __interrupt void cpu_timer0_isr(void) [ CpuTimer0.InterruptCount++; // Acknowledge this interrupt to receive more interrupts from group 1 PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; ] __interrupt void cpu_timer1_isr(void) [ CpuTimer1.InterruptCount++; // The CPU acknowledges the interrupt. EDIS; ] __interrupt void cpu_timer2_isr(void) [ EALLOW; CpuTimer2.InterruptCount++; // The CPU acknowledges the interrupt. EDIS; ] //=========================================================================== // No more. //=========================================================================== 如果您认为此问题已被解答,请在“这是否解答您的问题” 后,点击“是”按钮! 谢谢您的合作! |
|
|
|
|
|
|
|
wj24021040 发表于 2018-12-13 20:39 CpuTimer1.RegsAddr = &CpuTimer1Regs; // CpuTimer2.RegsAddr = &CpuTimer2Regs; // Initialize timer period to maximum: CpuTimer1Regs.PRD.all = 0x752A;//0.5MS//0xEA54; //0xEA54*16.67ns=1ms // CpuTimer2Regs.PRD.all = 0xFFFFFFFF; //Timer1 Free Run CpuTimer1Regs.TCR.bit.FREE = 1; // Make sure timers are started: CpuTimer1Regs.TCR.bit.TSS = 0; // CpuTimer2Regs.TCR.bit.TSS = 1; // Reload all counter register with period value: CpuTimer1Regs.TCR.bit.TRB = 1; // CpuTimer2Regs.TCR.bit.TRB = 1; // Reset interrupt counters: CpuTimer1.InterruptCount = 0; // CpuTimer2.InterruptCount = 0; ] 别人这里定时器的中断禁止了,那不是定时器没有定时的功能啊,没中断函数了,我不知道写这个定时器还由什么用,希望大神指点下。。谢谢 |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
601 浏览 0 评论
1654 浏览 0 评论
2096 浏览 0 评论
为啥BQ7693003DBTR芯片在和BQ769X0盒子通讯时收不到信号?
1542 浏览 0 评论
DSP 28027F 开发板 XDS100v2调试探针诊断日志显示了 Error -150 (SC_ERR_FTDI_FAIL)如何解决
1386 浏览 0 评论
AT32F407在USART2 DMA发送数据时,接包接到了要发送的数据,程序还是处于等待传输完成的标识判断中,为什么?
1794浏览 29评论
2821浏览 23评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
1748浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
1667浏览 14评论
两个TMP117传感器一个可以正常读取温度值,一个读取的值一直是0,为什么?
1681浏览 13评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-14 21:55 , Processed in 2.528715 second(s), Total 51, Slave 43 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1166