完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我想我的计时器是停止从UART获取所有数据:这里是我的代码:我曾经评论过://ababeltnt2;//tababySistMuleVCuto Enter();它开始工作的方式。BunButababelTnt2;IdababySistMuleVCuto Enter();进来的数据不是写的,但我需要它。IT数据不来自USATARI,不想继续等待我该怎么办?这是我的定时器代码:
以上来自于百度翻译 以下为原文 I think my timer is stop be from getting all the data from usart : here is my code : void Modbus_read(int size, int ask_number ) { unsigned char buffer[21] = {0}; unsigned char temp[ask_number]; int loop_time = size - 5; int i2 = 4; intTemp =0; int i; int t; int counter =1; float ff; char str2[4]; char intValue[1]; time_out = false; // EnableIntT2; //INTEnableSystemMultiVectoredInt(); for( t = 0 ; t < size; t++) { while(!DataRdyUART2()); { buffer[t] = ReadUART2(); } } DisableIntT2; Write_Usart(": completing answer = "); char RX_data = '0'; for( int t = 0; t <(buffer[2]/2); t++ ) { intTemp = (((unsigned int)buffer[i2] << 8) + (unsigned int)buffer[i2 +1]); sprintf(intValue,"%i",counter ); Write_Usart(intValue); Write_Usart(": Value is = "); sprintf(intValue,"%i",intTemp ); Write_Usart(intValue); Write_Usart("rn"); i2 = i2 + 2; counter++; } } once I commented out: // EnableIntT2; //INTEnableSystemMultiVectoredInt(); it started working the way it should. b any but EnableIntT2; INTEnableSystemMultiVectoredInt(); the data coming in was not write but I need it because it data does not come in from usart I do not want to keep waiting what should I do ? this is my timer code : extern "C" { void __ISR(_TIMER_1_VECTOR, ipl2) Timer1Handler(void){ if (Pump_Over_time == false) MotorRunTOOLong(); else MotorSleeptime(); mT1ClearIntFlag(); } void __ISR(_TIMER_2_VECTOR, ipl2) Timer2Handler(void){ int stop; if (modbus_counter <= modbus_rst) modbus_counter = modbus_counter + 1; else { modbus_counter =0; time_out = true; mT2ClearIntFlag(); } } } |
|
相关推荐
3个回答
|
|
你需要使用中断来从UART接收字符到缓冲区。现在,你只是在查询UART数据,这意味着如果有什么延迟你的轮询,你就错过了字符。
以上来自于百度翻译 以下为原文 You need to use interrupts to receive characters from the UART into a buffer. Right now, you're just polling for uart data, which means you miss characters if anything delays your polling. |
|
|
|
谢谢,我该怎么做?你能给我举个例子吗?
以上来自于百度翻译 以下为原文 thanks, how do I set that up ? can you show me an example ? |
|
|
|
不是我,我从来没有编程PIC32。你没有提到PIC32设备,你正在工作,或者如果你正在使用和谐或MCC。
以上来自于百度翻译 以下为原文 Not me, I've never programmed a PIC32. You did not mention what PIC32 device you are working on, or if you are using Harmony or MCC. |
|
|
|
只有小组成员才能发言,加入小组>>
5192 浏览 9 评论
2012 浏览 8 评论
1936 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3183 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2238 浏览 5 评论
746浏览 1评论
633浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
518浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
644浏览 0评论
544浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-1 17:45 , Processed in 1.400753 second(s), Total 83, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号