完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,GuySi想要做五分钟的延迟,所以我使用了DelayIMS内置的函数MIKROC,用于PIC编译程序的配置寄存器,并设置SHTTPS://Ibb. CO/KAJGYHH,但是它停止了,因为在延迟结束之后,我试图使ADC像0,所以PIN tiAC从不去任何变化1,所以在哪里是问题
以上来自于百度翻译 以下为原文 Hi guys i want to make five minutes delay so i used delay_ms built in function mikroC for pic compiler ***it triac at GP2_bit; ***it led at GP4_bit; unsigned int smokeLevel=0; unsigned long int counter=0; void main() { cmcon=7; TRISIO2_bit=0; TRISIO4_bit=0; ANSEL.ANS0=1; ANSEL.ANS2=0; ANSEL.ANS3=0; ADCON0.VCFG=0; triac=0; led=0; delay_ms(300000); // wait five minutes while(1) { smokeLevel=ADC_Read(0); if(smokeLevel<300) { triac=1; led=1; } else { triac=0; led=0; } } } scrennshoot for the config register and settings https://ibb.co/kAjGyH but it halt because after the delay end i try to make the ADC to be like 0 so the pin triac never goes 1 nothing changes so where is the problem |
|
相关推荐
19个回答
|
|
DelayyMs-()函数将接受的范围可能超出范围。在MikROC文档中:创建一个持续时间为毫秒(一个常数)的软件延迟。可应用的常数的范围取决于振荡器的频率。在时钟周期中,有4500个似乎是极限,所以您必须推导出DelayLyMs-()的最大参数是基于与振荡器频率相关的信息。实际上是NOP。最大值是45000000。你在4MHz,所以你的循环时间是0.00万,250.00万,25s,45000000=1125SSO。你的最大延迟时间(秒)延迟是1125s。如果你需要一个定时器5分钟,你可能不得不放弃一堆调用到DelayIsMs()(不推荐)或者使用硬件定时器ALON。把计数器和一个标志加起来计数5分钟。参见:HTTPS://FUMU.MikRO.COM/VIEW?t=8717
以上来自于百度翻译 以下为原文 You may be out of range for what the delay_ms() function will accept. In the MikroC documentation: Creates a software delay in duration of time_in_ms milliseconds (a constant). Range of applicable constants depends on the oscillator frequency. 45,000,000 seems to be the limit in clock cycles, so you will have to derive what your maximum argument for delay_ms() is based on that information alongside what your oscillator frequency is. delay_ms() calls delay_cyc(), which is basically a NOP. The max is 45,000,000. You're at 4MHz, so your cycle time is 0.00000025s 0.00000025s * 45,000,000 = 11.25s So your maximum delay_ms() delay is 11.25s. If you need a timer for 5 minutes, you'll probably either have to drop a bunch of calls to delay_ms() (would not recommend) or use a hardware timer alongside a counter and a flag to count up to 5 minutes. See: https://forum.mikroe.com/viewtopic.php?t=8717 |
|
|
|
我建议你试着减少延迟时间(也许是1000),看看你的程序是否有其他功能。这可能有助于你解决这些问题。
以上来自于百度翻译 以下为原文 I suggest you try reducing the delay time (maybe something like 1000) to see if the rest of your program functions. This may help point you to the issues. |
|
|
|
好的,我把这个计时器ODE读取模拟值10秒后延迟,不使用DelaysMs,但结果是相同的。什么也不干。它从来没有设置GPIO2,我在这里命名为“三端双向可控硅”是逻辑1,即使我使AN0连接到逻辑0哪里是问题!!!!!!!!
以上来自于百度翻译 以下为原文 ok i put this timer ode to read analog value after 10 SEC delay without using delay_ms but the result is the same . nothing work . it never set the GPIO2 which i named here "triac" to be logic 1 even if i make the AN0 connected to logic 0 //4Mhz internal clock ***it triac at GP2_bit; ***it led at GP4_bit; unsigned int smokeLevel1=0; unsigned int smokeLevel2=0; unsigned int smokeLevel=0; unsigned int oneMinuteCounter=0; unsigned int minutes=0; volatile unsigned int flag=0; void interrupt() { if (INTCON.TMR0IF==1) { oneMinuteCounter++; if(oneMinuteCounter>=918){minutes++;oneMinuteCounter=0;} if(minutes>=10){flag=1;minutes=0;} INTCON.TMR0IF = 0; } } void main() { cmcon=7; TRISIO2_bit=0; TRISIO4_bit=0; TRISIO3_bit=0; TRISIO0_bit=1; ANSEL.ANS0=1; ANSEL.ANS2=0; ANSEL.ANS3=0; ADCON0.CHS1=0; ADCON0.CHS0=0; ANSEL.ADCS0=1; ANSEL.ADCS1=0; ANSEL.ADCS2=1; ADCON0.ADFM=0; ADCON0.ADON=1; ADCON0.VCFG=0; TMR0=0; OPTION_REG.T0CS=0; OPTION_REG.PSA=0; OPTION_REG.PS0=1; OPTION_REG.PS1=1; OPTION_REG.PS2=1; INTCON.GIE=1; INTCON.T0IE=1; INTCON.PEIE=1; triac=0; Delay_ms(3); led=0; while(1) { if(flag==1) { ADCON0.B1=1; while(ADCON0.B1==1){} smokeLevel1=ADRESH; smokeLevel2=ADRESL; smokeLevel2=smokeLevel2>>6; smokeLevel1=smokeLevel1<<2; smokeLevel=smokeLevel1|smokeLevel2; //smokeLevel=ADC_Read(0); if(smokeLevel<500) { triac=1; Delay_ms(3); led=1; } else { triac=0; Delay_ms(3); led=0; } } } } Where is the problem !!!!!! |
|
|
|
|
|
|
|
你确定这些配置设置正在被编程到PIC中吗?我从来没有使用MikROC,所以我不知道涉及什么,但你的症状听起来很像WDT触发。
以上来自于百度翻译 以下为原文 Are you sure these config settings are getting programmed into the PIC? I've never used mikroC, so I don't know what is involved, but your symptoms sound a lot like the WDT triggering. |
|
|
|
我会检查你确定这些配置设置正在编程进入PIC吗?我从来没有使用MikROC,所以我不知道涉及什么,但你的症状听起来很像WDT触发。
以上来自于百度翻译 以下为原文 i will check it Are you sure these config settings are getting programmed into the PIC? I've never used mikroC, so I don't know what is involved, but your symptoms sound a lot like the WDT triggering. |
|
|
|
|
|
|
|
这是一个简单的程序读取ADC管脚在一定的分钟后,作出逻辑1或逻辑0的决定!!!!…我不相信我有麻烦!!
以上来自于百度翻译 以下为原文 it is so simple program to read ADC pin after certain number of minutes and make a decision with logic 1 or logic 0 !!! .. i dont believe that i have troubles with that !! |
|
|
|
如果WDT是启用的,那么你的程序是多么简单,而且你不经常重置它。除非你真的知道为什么需要它,否则你应该总是禁用它。
以上来自于百度翻译 以下为原文 It doesn't matter how simple your program is if the WDT is enabled, and you're not regularly resetting it. Unless you really know why you need it, you should always have it disabled. |
|
|
|
检查屏幕StuoToU会发现在PIC工具包程序员配置寄存器加载0x0194,这意味着WDT是Dababess MCLR是禁用的HTTPS://Ibb. CO/NE5SAX
以上来自于百度翻译 以下为原文 check the screenshoot u will find in the pic kit programmer the config register is loaded with 0x0194 which means WDT is disabled MCLR is disabled https://ibb.co/nE5SAx |
|
|
|
在数据表中有一句话说:“5:当MCLR在ItoSc或RC模式中声明时,内部时钟振荡器被禁用。”这意味着什么?
以上来自于百度翻译 以下为原文 There is a sentence in the datasheet that says "5: When MCLR is asserted in INTOSC or RC mode, the internal clock oscillator is disabled." what does that mean ? |
|
|
|
这意味着驱动MCLR引脚低会停止时钟。你有你的电路板的示意图吗?MCLR引脚是否拉高?在VSS和VDD管脚之间有旁路电容器吗?
以上来自于百度翻译 以下为原文 It means that driving the MCLR pin low will stop the clock. Do you have a schematic of your board? Is the MCLR pin pulled high? Do you have bypass capacitors between your VSS and VDD pins? |
|
|
|
|
|
|
|
我把MCLR引脚作为输入,它没有连接到任何在配置寄存器中的任何东西,McCrRE引脚是0,所以MCLR是Dababely:是的,我有电容器
以上来自于百度翻译 以下为原文 i make the MCLR pin as input it isn't connected to anything in the schematic in config register the MCLRE pin is 0 so MCLR is disabled yes i have capacitor |
|
|
|
不要离开MCLR引脚浮动。即使你禁用MCLR功能,如果它可以浮动到高电压,它可以触发编程模式,这看起来像一个重置。
以上来自于百度翻译 以下为原文 Don't leave the MCLR pin floating. Even if you disable the MCLR function, if it can float up to a high voltage, it can trigger programming mode, which looks just like a reset. |
|
|
|
一些较新的器件在MCLR引脚上有微弱的上拉。但不是在PIC12F675上。
以上来自于百度翻译 以下为原文 Some newer devices have a weak pullup on the MCLR pin. But not on the PIC12F675. |
|
|
|
如果我把所有未使用的引脚作为输出,并使它们全部生成逻辑1,该怎么办?会更好吗?
以上来自于百度翻译 以下为原文 what if i make all unused pins as output and make them all to generate logic 1 ? will be better ? |
|
|
|
更好的是,你不应该有浮动输入引脚。然而,你不能使MCLR引脚的输出,它只是输入,所以你不能避免需要安装一个上拉电阻到该引脚。
以上来自于百度翻译 以下为原文 Better yes, you should never have floating input pins. However, you cannot make the MCLR pin an output, it is input only, so you can't avoid the need to fit a pullup resistor to that pin. |
|
|
|
一般来说,设置逻辑0的输出要好一点,因为低侧N沟道晶体管的导通电阻低于P沟道晶体管的高侧。无论如何,将未使用的引脚设置为输出逻辑0或1,或者将它们作为电阻连接到VDD或VSS的输入端。R.
以上来自于百度翻译 以下为原文 Generally it's a bit better to set them logic 0 output, because the on resistance of the N channel transistor on the low side is lower than that of the P channel transistor on the high side. Anyway, set unused pins to output logic 0 or 1, or leave them as inputs connecting to Vdd or Vss by a resistor. |
|
|
|
只有小组成员才能发言,加入小组>>
5242 浏览 9 评论
2031 浏览 8 评论
1955 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3207 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2256 浏览 5 评论
778浏览 1评论
669浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
596浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
678浏览 0评论
577浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 20:22 , Processed in 1.686381 second(s), Total 112, Slave 96 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号