完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
包括:“延迟。H”//CONFIG,PracMig-COMFIG-COFC=hs//振荡器选择位(HS振荡器);在电路串行编程允许位(BR3为数字I/O,MCLR上的HV必须用于编程)的集合允许位(Bor禁用),LVP= OF//Low Voltage(单电源)。IG WRT=OF//Flash程序存储器写使能位(写保护断开;所有程序存储器可由ECOCON控制写入)我国现行的《系统》(空白){TrISC= 0B00亿;();(1){RC1=0;RC2=0;Delaym(100);RC1=1;RC2=1;DelayMs(100);}这是我的控制LED的代码。它工作良好,但它像PWM脉冲一样工作。
以上来自于百度翻译 以下为原文 #include #include "delay.h" // CONFIG #pragma config FOSC = HS // Oscillator Selection bits (HS oscillator) #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled) #pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled) #pragma config BOREN = OFF // Brown-out Reset Enable bit (BOR disabled) #pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming) #pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off) #pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control) #pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off) /************************************************************** Initialise System **************************************************************/ void System_init(void) { TRISC = 0b00000000; PORTC = 0b00000000; } /************************************************************** Main Program **************************************************************/ void main(void) { System_init(); while (1) { RC1 = 0; RC2 = 0; DelayMs(100); RC1 = 1; RC2 = 1; DelayMs(100); } } This is my code to control an LED.It working fine but it work like PWM pulse.LED dim instead of SWITCH OFF fully... How to change this..? |
|
相关推荐
10个回答
|
|
a)总是指定哪一个PICB)请使用代码TAGSC)你如何连接LED到你的输出(示意图)?
以上来自于百度翻译 以下为原文 a) Always specify which PIC b) please use code tags c) how did you connect the LEDs to your outputs (schematic)? |
|
|
|
这几乎可以肯定是某种类型的读修改写问题,你如何写到端口引脚,但很难给出好的建议,如果你不麻烦提到你正在使用的PIC设备。
以上来自于百度翻译 以下为原文 This is almost certainly some sort of read-modify-write problem in how you are writing to the PORT pins, but difficult to give good advice if you don't bother mentioning which PIC device you are using. |
|
|
|
增加延迟到1秒。你期望在100Ms发生什么?每秒10次,坚持视觉,你的大脑不够快,分辨不出。LED会有淡出时间。
以上来自于百度翻译 以下为原文 Increase delay to 1 sec. What do you expect to happen at 100ms? 10 times a second, persistance of vision, your brain is not fast enough to tell the difference. Leds will have a fade out time. |
|
|
|
它每秒闪烁5次,而不是10次。即使是每秒10次,也很容易辨别出来。
以上来自于百度翻译 以下为原文 It's blinking 5 times a second, not 10. And even at 10 times a second, it's easily discerned. |
|
|
|
因为你在配置比特中使用了HS振荡器模式。老实说,你在最小的HS振荡器模式下使用哪一个PIC并不重要,你的时钟周期是2MHz或200毫秒,即使你的延时为100ms,它仍然可能太快,我们的眼睛不能区分开和关。因此,让你的延迟更长时间,让ON和OFF循环更多的时间,这样你就可以看到它闪烁。如果你仍然有问题,那么你将需要指定哪一个PIC,所以我们可以看看为什么会发生这种情况。
以上来自于百度翻译 以下为原文 John_ive, since you are using HS oscillator mode in your configuration bits. Truthfully it doesn't matter which PIC you are using at the minimum HS oscillator mode 8MHz your clock cycle is 2MHz or 200nS even with your delay of 100mS it still could be too fast for our eyes to distinguish between on and off. so make your delay longer to give the on and off cycle more time so you can see it blink. If you still have problems then you will need to specify which PIC so we can look at why this could be happening. Jamus |
|
|
|
嗨,原来的消息不说什么频率连接到振荡器引脚的晶体被调谐到没有宏或其他定义告诉DelayMs(…)函数系统时钟应该运行什么频率,所以没有办法知道100毫秒是真的100毫秒,或一些非常。不同的。迈西尔
以上来自于百度翻译 以下为原文 Hi, Original message do not say what frequency the crystal connected to oscillator pins is tuned to. There is no Macro or other definition telling DelayMs(...) function what frequency the system clock is supposed to be running, so there is no way to know if 100 ms is really 100 ms, or something very different. Mysil |
|
|
|
有一个非标准文件包括“延迟.H”。谁知道里面可能有什么…
以上来自于百度翻译 以下为原文 There is a non-standard file included called "delay.h". Who knows what might be in there... |
|
|
|
我认为你必须写:(a)定义xTalthFrq 8000000;(例如:8MHz),使用α-DelayyMs(x)OSCCon=…;或OSCCON1或OSCCON2或OSCFRQ取决于PIC使用1个LED的2个端口引脚?
以上来自于百度翻译 以下为原文 I think you have to write: #define _XTAL_FREQ 8000000 ; (eg:8MHz) for using __delay_ms(x) OSCCON=....; or OSCCON1 or OSCCON2 or OSCFRQ depends PIC used you use 2 port pins for 1 led? |
|
|
|
也许,他不使用y-DelayyMs-(),实际上他使用DelayMs(),但没有显示它是如何定义的。
以上来自于百度翻译 以下为原文 Maybe, however he is not using __delay_ms(), he's actually using DelayMs() but has not shown how it is defined. |
|
|
|
约翰逊,你有什么建议吗?詹纳斯
以上来自于百度翻译 以下为原文 John_ive, Did any of the suggestions work for you? Jamus |
|
|
|
只有小组成员才能发言,加入小组>>
5287 浏览 9 评论
2056 浏览 8 评论
1968 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3232 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2277 浏览 5 评论
820浏览 1评论
709浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
654浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
710浏览 0评论
607浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-1-13 01:49 , Processed in 1.434449 second(s), Total 95, Slave 79 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号