完善资料让更多小伙伴认识你,还能领取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; ] 别人这里定时器的中断禁止了,那不是定时器没有定时的功能啊,没中断函数了,我不知道写这个定时器还由什么用,希望大神指点下。。谢谢 |
|
|
|
|
|
只有小组成员才能发言,加入小组>>
NA555DR VCC最低电压需要在5V供电,为什么用3.3V供电搭了个单稳态触发器也使用正常?
707 浏览 3 评论
MSP430F249TPMR出现高温存储后失效了的情况,怎么解决?
617 浏览 1 评论
对于多级放大电路板,在PCB布局中,电源摆放的位置应该注意什么?
1079 浏览 1 评论
773 浏览 0 评论
普中科技F28335开发板每次上电复位后数码管都会显示,如何熄灭它?
537 浏览 1 评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
183浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
145浏览 14评论
两个TMP117传感器一个可以正常读取温度值,一个读取的值一直是0,为什么?
10浏览 13评论
在使用3254进行录音的时候出现一个奇怪的现象,右声道有吱吱声,请教一下,是否是什么寄存器设置存在问题?
137浏览 13评论
TLV320芯片内部自带数字滤波功能,请问linein进来的模拟信号是否是先经过ADC的超采样?
130浏览 12评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-3 00:03 , Processed in 1.069496 second(s), Total 55, Slave 47 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号