完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我使用的是PIC24FJ128GA310。我的程序逻辑有两个问题:1。我的应用程序包括2个传输:TX1和TX2在45秒的时间间隔。在无限循环中,TX1必须保持每45秒发送一次,但是一旦RTCC警报到来,TX1必须停止,TX2必须以45秒间隔连续发送4次。一旦TX2完成,那么TX1可以再次回到无限传输。我尝试遵循不工作的逻辑2.上面的RTCKI ISR工作吗?它包括嵌套中断time1和32位时间2-3。它只传输了4次,有什么建议吗?
以上来自于百度翻译 以下为原文 I am using pic24fj128ga310. I have two problems in my program logic: 1. My application includes 2 transmission: TX1 and TX2 at 45 sec interval. In an infinit loop TX1 has to keep transmiting every 45 sec, but as soon as RTCC alARM comes TX1 has to stop and TX2 has to transmit 4 times continously at 45 sec interval.once TX2 completes then TX1 can again go back to infinite transmission. I tried following logic which did not work void __attribute__((interrupt, no_auto_psv)) _RTCCInterrupt(void){ IFS3bits.RTCIF = 0; int counter=0; counter++; flag_5sec = 1; if(flag_5sec){ //counter == 5 flag_5sec = 0; PTT_PWR = OFF; Delay_msec(1000); INSAT_PWR = ON; INSAT_select(); Delay_msec(2000); putsNUART4((unsigned int*)buff,sprintf(buff,"@#NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA2")); Delay_32bit_Sec(32); putsNUART4((unsigned int*)buff,sprintf(buff,"@#NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA2")); Delay_32bit_Sec(32); putsNUART4((unsigned int*)buff,sprintf(buff,"@#NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA2")); Delay_32bit_Sec(32); // PTT_PWR = ON; // PTT_select(); } } /**********infinite loop in main***********************/ PTT_PWR = ON; PTT_select(); while(1){ putsNUART4((unsigned int*)buff,sprintf(buff,"FFFFFFFFFFFFFFFFFFFFF")); Delay_32bit_Sec(32); putsNUART4((unsigned int*)buff,sprintf(buff,"FFFFFFFFFFFFFFFFFFFFF")); Delay_32bit_Sec(32); } 2.will the above RTCC_ISR work? It includes nested interrupts timer1 and 32bit timer2-3. It did not transmitted 4 times only once it transmitted. Any suggestions? |
|
相关推荐
3个回答
|
|
澄清:FFFFFFF是TX1,@α-NaAAAA是TX2。
以上来自于百度翻译 以下为原文 To clarify: FFFFFFF is TX1, and @#NAAAAA is TX2 |
|
|
|
在ISR中执行耗时的任务通常是个坏主意。此外,一些函数可能不能重新进入,这可能会导致更多的问题。如果在ISR中设置一个标志并从主循环发送字节会更好。
以上来自于百度翻译 以下为原文 It's usually a bad idea to perform time-consuming tasks in a ISR. Also, some functions may not be re-enterable, and this could cause more problems. It would be better if you raise a flag in the ISR and send bytes from main loop |
|
|
|
标准库函数可能不是线程安全的(多个ISR不应该使用它们,因为嵌套的中断意味着一个ISR可以中断另一个优先级较低的ISR)。在ISR中延迟。您建议的逻辑应该在main()循环中完成,ISR只是设置状态变量来通知主循环它应该采取什么代码分支。
以上来自于百度翻译 以下为原文 standard library functions may not be thread safe (multiple ISR should not use them, because a nested interrupt means one ISR can interrupt another of lower priority). And as CinziaG says, one probably should not be doing a CPU intensive function call to sprintf in an ISR. you should definitely not do delays in an ISR. the logic you propose should be done in the main() loop and the ISR's just set state variables to inform the main loop as to what code branch it should take. |
|
|
|
只有小组成员才能发言,加入小组>>
5238 浏览 9 评论
2028 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3204 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
778浏览 1评论
666浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
595浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
677浏览 0评论
576浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 11:04 , Processed in 1.214995 second(s), Total 50, Slave 44 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号