完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我需要在32兆赫内部运行,我使用PIC16F179(SOIC),4VDC从PICtiT3,XC8,MPLABX V3.50,没有晶体,10K从MCLR上拉到4VDC,我正在测试RC5引脚,我的代码:在示波器RC5:1.37 US =高,1.26Us= LoW请,有什么建议吗?…谢谢您。
以上来自于百度翻译 以下为原文 I need run at 32MHZ internal, I use PIC16F1769(SOIC), 4VDC from PicKit3, XC8, MPLABX v3.50, No crystal, 10K pull-up from MCLR to 4VDC, I am testing RC5 pin, my code: #pragma config FOSC = INTOSC // Oscillator Selection Bits (INTOSC oscillator: I/O function on CLKIN pin) #pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled) #pragma config PWRTE = ON // Power-up Timer Enable (PWRT enabled) #pragma config MCLRE = ON // MCLR Pin Function Select (MCLR/VPP pin function is MCLR) #pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled) #pragma config BOREN = OFF // Brown-out Reset Enable (Brown-out Reset disabled) #pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin) #pragma config IESO = ON // Internal/External Switchover Mode (Internal/External Switchover Mode is enabled) #pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is enabled) // CONFIG2 #pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off) #pragma config PPS1WAY = OFF // Peripheral Pin Select one-way control (The PPSLOCK bit can be set and cleared repeatedly by software) #pragma config ZCD = OFF // Zero-cross detect disable (Zero-cross detect circuit is disabled at POR) #pragma config PLLEN = ON // Phase Lock Loop enable (4x PLL is always enabled) #pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset) #pragma config BORV = LO // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.) #pragma config LPBOR = OFF // Low-Power Brown Out Reset (Low-Power BOR is disabled) #pragma config LVP = ON // Low-Voltage Programming Enable (Low-voltage programming enabled) #include #define _XTAL_FREQ 32000000 void main(void) { OSCCON = 0b11110000; ANSELA = 0; ANSELB = 0; ANSELC = 0; TRISA = 0; TRISB = 0; TRISC = 0; LATA = 0; LATB = 0; LATC = 0; WPUA = 0; WPUB = 0; WPUC = 0; while(1) { LATCbits.LATC5 = !LATCbits.LATC5; } } In the Oscilloscope at RC5: 1.37uS=HIGH, 1.26uS=LOW Please, any suggestions?... Thank you. |
|
相关推荐
8个回答
|
|
C代码需要几个指令来组织循环并设置位,这样就不会以这种方式来测量速度。相反,启用CKUutEN并在时钟输出时观察FoSc/ 4。
以上来自于百度翻译 以下为原文 C code takes several instruction to organize the loop and set the bit, so you won't measure your speed this way. Instead, enable CLKOUTEN and observe FOSC/4 at the clock output. |
|
|
|
引脚RA4(ClkOUT)在示波器8MHz=&;福斯克/ 4=8MHz…FoCC=32 MHZZ,但LED开/关时间不好。
以上来自于百度翻译 以下为原文 Pin RA4 (CLKOUT) at oscilloscope 8MHZ => FOSC/4=8MHZ ... FOSC = 32MHZ but the time of led on/off is bad. |
|
|
|
它是怎样的“坏”?你的意思是你预期的高和低时期是相同的吗?还是更高频率?
以上来自于百度翻译 以下为原文 How is it "bad"? Do you mean you are expecting the high and low periods to be the same? Or at a higher frequency? |
|
|
|
我改为:现在是高= 125Ns,低= 375纳秒…好,现在中断不能正常工作。我补充说:在示波器RC5每2MS改变状态,但必须是每16U。有什么建议吗?
以上来自于百度翻译 以下为原文 I changed to: while(1) { asm("bsf LATC,5"); asm("bcf LATC,5"); } and now is well HIGH=125nS, LOW=375nS ... OK. Now the interrupt don't work correctly. I added: void interrupt SYS_InterruptHigh() { if (INTCONbits.TMR0IF==1) { LATCbits.LATC5 = !LATCbits.LATC5; TMR0 = 0x80; // 16uS = 125nS * (256-128) OPTION_REG = 0x06; // Prescaler = 128 INTCONbits.TMR0IF = 0; } } void main(void) { OSCCON = 0b11110000; ANSELA = 0; ANSELB = 0; ANSELC = 0; TRISA = 0; TRISB = 0; TRISC = 0; LATA = 0; LATB = 0; LATC = 0; WPUA = 0; WPUB = 0; WPUC = 0; TMR0 = 0x80; // 16uS = 125nS * (256-128) OPTION_REG = 0x06; // Prescaler = 128 INTCONbits.TMR0IF = 0; INTCONbits.TMR0IE = 1; INTCONbits.GIE = 1; INTCONbits.PEIE = 1; while(1); } At oscilloscope RC5 change state every 2mS but must be every 16uS. Any suggestions? |
|
|
|
125NS×128预分频器=16US,* 128(定时器重载)=约2MS
以上来自于百度翻译 以下为原文 125nS * 128 prescaler = 16uS, *128 (timer reload) = circa 2mS |
|
|
|
你有预分频器设置的FoCC / 4(8兆赫)分128。这导致一个时钟频率为8MHz / 128=62.5 kHz的时钟。这是一个0.016毫秒的周期,当计算128个周期(即Time0的0x80设置)给你2.048毫秒时,禁用预分频器。
以上来自于百度翻译 以下为原文 You have the prescaler set to divide the Fosc/4 (8 Mhz) by 128. This results in a timer0 clock frequency of 8Mhz/128 = 62.5 khz. That is a period of 0.016 ms which when counted for 128 cycles (that is the 0x80 setting of the timer0) gives you 2.048 ms. Disable the prescaler. |
|
|
|
谢谢你,你是对的,我已经改正了。谢谢你。
以上来自于百度翻译 以下为原文 Thank you CinziaG and jack@kksound, You are right, I already corrected it. Thank you. |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
5228 浏览 9 评论
2026 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3199 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
770浏览 1评论
658浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
585浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
668浏览 0评论
570浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-18 10:28 , Processed in 1.487842 second(s), Total 90, Slave 74 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号