完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
各位老师好,我正在学习f28035,用的controlSUITE中的例程,我看到程序中都是这么用时钟 的,先把程序粘贴如下。为什么在系统中要设置时钟在下面这几个函数之间一直循环,作用是什么?另外系统中断是采用定时器中断还是CPU中断,这个在哪有配置呢?
非常感谢!!! void A0(void) [ if(Cputimer0Regs.TCR.bit.TIF == 1) [ CpuTimer0Regs.TCR.bit.TIF = 1; //----------------------------------------------------------- (*A_Task_Ptr)(); // jump to an A Task (A1,A2,A3,...) //----------------------------------------------------------- VTimer0[0]++; // virtual timer 0, instance 0 (spare) SerialCommsTimer++; ] Alpha_State_Ptr = &B0; // Comment out to allow only A tasks ] void B0(void) [ if(CpuTimer1Regs.TCR.bit.TIF == 1) [ CpuTimer1Regs.TCR.bit.TIF = 1; //----------------------------------------------------------- (*B_Task_Ptr)(); // jump to a B Task (B1,B2,B3,...) //----------------------------------------------------------- VTimer1[0]++; // virtual timer 1, instance 0 (spare) ] Alpha_State_Ptr = &C0; // Allow C state tasks ] void C0(void) [ if(CpuTimer2Regs.TCR.bit.TIF == 1) [ CpuTimer2Regs.TCR.bit.TIF = 1; //----------------------------------------------------------- (*C_Task_Ptr)(); // jump to a C Task (C1,C2,C3,...) //----------------------------------------------------------- VTimer2[0]++; //virtual timer 2, instance 0 (spare) ] Alpha_State_Ptr = &A0; // Back to State A0 ] //================================================================================= // A - TASKS (executed in every 1 msec) //================================================================================= //-------------------------------------------------------- void A1(void) // SPARE (not used) [ if (Disable==1) [ EALLOW; EPwm1Regs.TZFRC.bit.OST=1; EPwm2Regs.TZFRC.bit.OST=1; EPwm3Regs.TZFRC.bit.OST=1; EPwm4Regs.TZFRC.bit.OST=1; EDIS; ] A_Task_Ptr = &A2; ] void A2(void) // SPARE (not used) [ //the next time CpuTimer0 'counter' reaches Period value go to A3 A_Task_Ptr = &A3; ] void A3(void) // SPARE (not used) [ //the next time CpuTimer0 'counter' reaches Period value go to A1 A_Task_Ptr = &A1; ] //================================================================================= // B - TASKS (executed in every 5 msec) //================================================================================= void B1(void) // Toggle GPIO-00 [ //the next time CpuTimer1 'counter' reaches Period value go to B2 B_Task_Ptr = &B2; ] void B2(void) // SPARE [//the next time CpuTimer1 'counter' reaches Period value go to B3 B_Task_Ptr = &B3; ] void B3(void) // SPARE [ //the next time CpuTimer1 'counter' reaches Period value go to B1 B_Task_Ptr = &B1; //----------------- ] //================================================================================= // C - TASKS (executed in every 50 msec) //================================================================================= void C1(void) // Toggle GPIO-34 [ GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1; // Blink LED //----------------- //the next time CpuTimer2 'counter' reaches Period value go to C2 C_Task_Ptr = &C2; ] void C2(void) // SPARE [ //the next time CpuTimer2 'counter' reaches Period value go to C3 C_Task_Ptr = &C3; ] void C3(void) // SPARE [ //the next time CpuTimer2 'counter' reaches Period value go to C1 C_Task_Ptr = &C1; ] |
|
相关推荐
8 个讨论
|
|
并没有真正触发CPU中断,只是利用定时器的计数匹配标志位来判断是否已经计数到设定时间,来定时调度一个任务,举个例子 void A0(void) [ if(CpuTimer0Regs.TCR.bit.TIF == 1) [ CpuTimer0Regs.TCR.bit.TIF = 1; //----------------------------------------------------------- (*A_Task_Ptr)(); // jump to an A Task (A1,A2,A3,...) //----------------------------------------------------------- VTimer0[0]++; // virtual timer 0, instance 0 (spare) SerialCommsTimer++; ] Alpha_State_Ptr = &B0; // Comment out to allow only A tasks ] void B0(void) [ if(CpuTimer1Regs.TCR.bit.TIF == 1) [ CpuTimer1Regs.TCR.bit.TIF = 1; //----------------------------------------------------------- (*B_Task_Ptr)(); // jump to a B Task (B1,B2,B3,...) //----------------------------------------------------------- VTimer1[0]++; // virtual timer 1, instance 0 (spare) ] Alpha_State_Ptr = &C0; // Allow C state tasks ] void C0(void) [ if(CpuTimer2Regs.TCR.bit.TIF == 1) [ CpuTimer2Regs.TCR.bit.TIF = 1; //----------------------------------------------------------- (*C_Task_Ptr)(); // jump to a C Task (C1,C2,C3,...) //----------------------------------------------------------- VTimer2[0]++; //virtual timer 2, instance 0 (spare) ] Alpha_State_Ptr = &A0; // Back to State A0 ] //================================================================================= // A - TASKS (executed in every 1 msec) //================================================================================= //-------------------------------------------------------- void A1(void) // SPARE (not used) [ if (Disable==1) [ EALLOW; EPwm1Regs.TZFRC.bit.OST=1; EPwm2Regs.TZFRC.bit.OST=1; EPwm3Regs.TZFRC.bit.OST=1; EPwm4Regs.TZFRC.bit.OST=1; EDIS; ] A_Task_Ptr = &A2; ] void A2(void) // SPARE (not used) [ //the next time CpuTimer0 'counter' reaches Period value go to A3 A_Task_Ptr = &A3; ] void A3(void) // SPARE (not used) [ //the next time CpuTimer0 'counter' reaches Period value go to A1 A_Task_Ptr = &A1; ] //================================================================================= // B - TASKS (executed in every 5 msec) //================================================================================= void B1(void) // Toggle GPIO-00 [ //the next time CpuTimer1 'counter' reaches Period value go to B2 B_Task_Ptr = &B2; ] void B2(void) // SPARE [//the next time CpuTimer1 'counter' reaches Period value go to B3 B_Task_Ptr = &B3; ] void B3(void) // SPARE [ //the next time CpuTimer1 'counter' reaches Period value go to B1 B_Task_Ptr = &B1; //----------------- ] //================================================================================= // C - TASKS (executed in every 50 msec) //================================================================================= void C1(void) // Toggle GPIO-34 [ GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1; // Blink LED //----------------- //the next time CpuTimer2 'counter' reaches Period value go to C2 C_Task_Ptr = &C2; ] void C2(void) // SPARE [ //the next time CpuTimer2 'counter' reaches Period value go to C3 C_Task_Ptr = &C3; ] void C3(void) // SPARE [ //the next time CpuTimer2 'counter' reaches Period value go to C1 C_Task_Ptr = &C1; ] 红色框部分是CPUtimer0计时到你设定时间,就会CpuTimer1Regs.TCR.bit.TIF 标志位等于1,所以任务A0就会判断通过,来运行,然后运行完,会把指针给到任务B,这样CPUtimer1定时到时间,如黄色部分,就会运行B0任务,然后再把指针扔个C任务,这样来回的调度。可以理解为一个小操作系统 A0任务下会有子任务A1,A2,A3。B C也同样。 |
|
|
|
|
|
Jazzye 发表于 2018-9-29 09:56 1、但是,在程序中只存在PWM错误联防程序,没有执行其他的任务,这样和直接用一个定时器定时有什么区别呢? 这只是C2000例程一个模板,这个例程只有这一个功能,但是其他例程可能会有很多后台任务就需要这样方法来调度。 2、程序中没有设定系统总中断是用哪个定时器中断,这个怎么判断呢? 你指的系统中断是什么中断?要这个中断什么功能?系统总中断只是一个bit,用来允许PWM或者ADC的中断被CPU触发执行 |
|
|
|
|
|
只有小组成员才能发言,加入小组>>
340 浏览 1 评论
533 浏览 2 评论
NA555DR VCC最低电压需要在5V供电,为什么用3.3V供电搭了个单稳态触发器也使用正常?
777 浏览 3 评论
MSP430F249TPMR出现高温存储后失效了的情况,怎么解决?
653 浏览 1 评论
对于多级放大电路板,在PCB布局中,电源摆放的位置应该注意什么?
1132 浏览 1 评论
AT32F407在USART2 DMA发送数据时,接包接到了要发送的数据,程序还是处于等待传输完成的标识判断中,为什么?
63浏览 29评论
162浏览 23评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
253浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
203浏览 14评论
两个TMP117传感器一个可以正常读取温度值,一个读取的值一直是0,为什么?
60浏览 13评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 23:16 , Processed in 1.222902 second(s), Total 73, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号