完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
两个完全对称的任务只是传入一个参数选择两组数据两个任务运行时要调用一个AD采样函数现在出现的问题是一个任务开始采样后另一个一开始第一个任务采样就停了
void Task_Power1() { Task_Power(0); } void Task_Power2() { Task_Power(1); } void Task_Power(u8 chx) 两个任务运行后是阻塞的 |
|
相关推荐
3个回答
|
|
AD采用能2个任务同时进行么?
|
|
|
|
正因为不行才出现问题了能不能用信号量邮箱来互斥呢就是当一个任务占用AD时不允许其他任务使用只有这个任务释放AD才能使用
|
|
|
|
请原子大哥指点
u16 ADCColl(u8 channel,u8 i){ //FeedDog(); if(i<16)chselect(i); ADC_ClearFlag(ADC1, ADC_FLAG_EOC); ADC_RegularChannelConfig(ADC1, channel, 1, ADC_SampleTime_239Cycles5); ADC_SoftwareStartConvCmd(ADC1, ENABLE); while(!(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC))); ADC_ClearFlag(ADC1, ADC_FLAG_EOC); return ADC_GetConversionValue(ADC1); }这是那个被两个任务调用的函数 void RefreshData(char channelx){ u16 i,ADch,tmp1; s16 temp; u32 ADsum[ADNUM2]; OSTimeDlyHMSM(0, 0, 0, 300); for(ADch = CH1ADB1; ADch < ADNUM2; ADch++){ ADsum[ADch] = 0;} for(i = 0; i < ADSAMP_NUM; i++) { if(channelx==0) { for(ADch = CH1ADB1; ADch < CH2ADB1; ADch++) { ADsum[ADch] += ADCColl(channel[ADch],ADch);//(enum ADCHANNELX) } } if(channelx==1) { for(ADch = CH2ADB1; ADch < DCVIN; ADch++) { ADsum[ADch] += ADCColl(channel[ADch],ADch);//(enum ADCHANNELX) } } for(ADch = DCVIN; ADch < ADNUM2; ADch++) { ADsum[ADch] += ADCColl(channel[ADch],ADch);//(enum ADCHANNELX) } } for(ADch = CH1ADB1; ADch < ADNUM2; ADch++){ ADsum[ADch] /= ADSAMP_NUM; } switch(channelx) { case 0: for(i = CH1ADB1; i < CH1DCC; i++){ run[channelx].VB[i+1] = COVER_B16(ADsum);//*CALIVOL/calivalue; if(run[channelx].VB[i+1] < 500) run[channelx].VB[i+1] = 0; } temp = COVER_CC(ADsum[ADCUR1]); //if((temp > 10)&&(temp < 1000))temp -= (run.SCC*(10-temp/100)/10); run[channelx].CC = temp/* * CALICC/calivalue[ADCUR1] */- run[channelx].SCC;////屏蔽校准 if(run[channelx].CC < 10)run[channelx].CC = 0; run[channelx].DC = COVER_DC(ADsum[CH1DCC]) - run[channelx].SDC;//)*CALIDC/calivalue[ADDC]; if(run[channelx].DC < 10)run[channelx].DC = 0; run[channelx].VIN = COVER_BPNI(ADsum[DCVIN]); if(run[channelx].VIN < 50)run[channelx].VIN = 0; run[channelx].VOUT= (COVER_BPNI(ADsum[CH1BV])/**CALIVOL*4/calivalue[CH1BV]*/) - (run[channelx].CC/ 100);////屏蔽校准 if(run[channelx].VOUT < 50)run[channelx].VOUT = 0; tmp1 = COVER_NTCV(ADsum[ADNTC1]);//求电压 tmp1 = COVER_NTCR(tmp1);//求电阻 run[channelx].NTC = COVER_NTC((float)tmp1/1000);//求温度 if((run[channelx].NTC < -10)||(run[channelx].NTC > 100)) ///run[channelx].NTC = -100; run[channelx].NTC = 30; tmp1 = COVER_NTCV(ADsum[ADBT1]);//求电压 tmp1 = COVER_NTCR(tmp1);//求电阻 run[channelx].BNTC = COVER_NTC((float)tmp1/1000);//求温度 if((run[channelx].BNTC < -10)||(run[channelx].BNTC > 100)) ///run[channelx].BNTC = -100; run[channelx].BNTC = 30; break; case 1:for(i = CH2ADB1; i < CH2DCC; i++){ run[channelx].VB[i-7] = COVER_B16(ADsum);//*CALIVOL/calivalue; if(run[channelx].VB[i-7] < 500) run[channelx].VB[i-7] = 0; } temp = COVER_CC(ADsum[ADCUR2]); //if((temp > 10)&&(temp < 1000))temp -= (run.SCC*(10-temp/100)/10); run[channelx].CC = temp /** CALICC/calivalue[ADCUR2]*/ - run[channelx].SCC; if(run[channelx].CC < 10)run[channelx].CC = 0; run[channelx].DC = COVER_DC(ADsum[CH2DCC]) - run[channelx].SDC;//)*CALIDC/calivalue[ADDC]; if(run[channelx].DC < 10)run[channelx].DC = 0; run[channelx].VIN = COVER_BPNI(ADsum[DCVIN]); if(run[channelx].VIN < 50)run[channelx].VIN = 0; run[channelx].VOUT= (COVER_BPNI(ADsum[CH2BV])/**CALIVOL*4/calivalue[CH2BV]*/) - (run[channelx].CC/ 100); if(run[channelx].VOUT < 50)run[channelx].VOUT = 0; tmp1 = COVER_NTCV(ADsum[ADNTC2]);//求电压 tmp1 = COVER_NTCR(tmp1);//求电阻 run[channelx].NTC = COVER_NTC((float)tmp1/1000);//求温度 if((run[channelx].NTC < -10)||(run[channelx].NTC > 100)) ///run[channelx].NTC = -100; run[channelx].NTC = 30; tmp1 = COVER_NTCV(ADsum[ADBT2]);//求电压 tmp1 = COVER_NTCR(tmp1);//求电阻 run[channelx].BNTC = COVER_NTC((float)tmp1/1000);//求温度 if((run[channelx].BNTC < -10)||(run[channelx].BNTC > 100)) ////run[channelx].BNTC = -100; run[channelx].BNTC = 30; break; default: break; } FANProc(); } 这是调用AD转换的函数 |
|
|
|
只有小组成员才能发言,加入小组>>
791 浏览 0 评论
1151 浏览 1 评论
2527 浏览 5 评论
2860 浏览 9 评论
移植了freeRTOS到STMf103之后显示没有定义的原因?
2710 浏览 6 评论
keil5中manage run-time environment怎么是灰色,不可以操作吗?
1071浏览 3评论
194浏览 2评论
456浏览 2评论
369浏览 2评论
M0518 PWM的电压输出只有2V左右,没有3.3V是怎么回事?
454浏览 1评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-22 17:29 , Processed in 0.656456 second(s), Total 81, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号