完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
你好朋友们,我正在使用PIC18F450,我正在尝试使用定时器来产生一个200 KHz的脉冲。我使用的是20MHz晶体,使用time1。我使用下面的配置,和RealalIZETMR1L=200;但是仍然在RA5中产生脉冲的输出是非常低的。有人能帮我配置时钟和计时器来产生200兆赫吗?{ Primamatlab配置文件PLLDIV=5×PrimaMatlab配置文件CPUDIV= OSC2OLPLL3A PrimaMac配置文件UBDIV=1×PracMA配置FoCC=HSPLLL HSY
以上来自于百度翻译 以下为原文 Hello friends, I am using PIC18F4550, I am trying to use timer to generate a pulse of 200kHz. I am using 20MHz crystal and use TIMER1. I use configuration as below, and initialize TMR1L = 200; but still the output at RA5 where I generate the pulse, is very low. Can some one please help me to configure the clock and timer to generate 200MHz ? #pragma config PLLDIV = 5 #pragma config CPUDIV = OSC2_PLL3 #pragma config USBDIV = 1 #pragma config FOSC = HSPLL_HS Thanks |
|
相关推荐
11个回答
|
|
|
您不能通过将值写入TMR1L一次来设置速率。您需要使用Time2,它具有PR寄存器,或者您需要一个中断服务例程,它在每次翻转后重新初始化计时器值。我们需要看到您的所有代码来查看您是否做得足够。
以上来自于百度翻译 以下为原文 You can't set a rate by writing a value to TMR1L once. You either need to use TIMER2, which has a PR register, or you need an interrupt service routine which reinitialises the timer value after every rollover. We would need to see ALL your code to see of you are doing enough. |
|
|
|
|
|
谢谢兄弟。我按你的建议去做了。它工作,但没有运行其他功能的空间。整个时间控制器忙着中断。这里是代码,定义了xTalthFrime2000 000 000 It计数=0;空隙中断ISR(空隙){if(pRI1BIT.TMR2IF=1){{PIR2IF=0;ToGGLE());}空主(空隙){T2CONTITS.TMR2ON=1;TrasabITS.RA5=0;LababITIs.La5=0;RCONBITS。IPEN=1;IPR1BIT.TMR2IP=1;=1;int=1;int=1;INTCONBITE。TMR0IP=1;Py1BIT.TMR2IE=1;IPR1BIT.TMR2IP=1;T2CON= 0B000 11100;PRC1L= 0B000 011110;CCP1CON=0B00 00 1100;T2CONTITS。TMR2ON=1;int i;而(1){计数=计数+1;(i=0;I)!= 50;i++){;} Labb.Lb0=Labbist.Lb0;}无效切换(空隙){LababIT.La5= ~LababITI. LA5;}。
以上来自于百度翻译 以下为原文 Thanks brother. I tried as you suggested. It works but there is no room to run other functions. Whole time controller is busy with the interrupt. Here is the code, #define _XTAL_FREQ 20000000 int count =0 ; void toggle(void); void interrupt ISR(void) { if(PIR1bits.TMR2IF == 1) { PIR1bits.TMR2IF = 0; toggle(); } } void main(void) { T2CONbits.TMR2ON = 1; TRISAbits.RA5 = 0; LATAbits.LA5 = 0; RCONbits.IPEN = 1; IPR1bits.TMR2IP = 1; INTCONbits.GIE = 1; INTCONbits.PEIE = 1; INTCONbits.TMR0IE = 1; INTCON2bits.TMR0IP = 1; PIE1bits.TMR2IE = 1; IPR1bits.TMR2IP = 1; T2CON = 0b00000100; PR2 = 0b00111011; CCPR1L = 0b00011110; CCP1CON = 0b00001100; T2CONbits.TMR2ON = 1; int i; while(1) { count = count + 1; for (i=0;i!=50;i++) { ; } LATBbits.LB0 = ~LATBbits.LB0 ; } } void toggle(void) { LATAbits.LA5 = ~LATAbits.LA5; } |
|
|
|
|
|
|
|
|
|
|
|
这意味着什么?当中断服务没有处理时,为什么启用Time0中断?当只有一个中断服务时,为什么要启用中断优先级?
以上来自于百度翻译 以下为原文 What does this mean? Why are you enabling Timer0 interrupts when your interrupt service is not handling them? Why are you enabling interrupt priorities when you only have a single interrupt service? |
|
|
|
|
|
在我们的应用中,我想用这个脉冲来驱动伺服电机,速度控制(脉冲频率)和旋转控制(脉冲数)。我认为这是不可能的PWM生成,所以我试图找出一个PWM和中断的组合。同时,我们的最大脉冲频率要求是200 kHz,这是不可能的定时器中断。请指正。如果你有任何解决方案,我可以请你分享吗?谢谢
以上来自于百度翻译 以下为原文 In our application, I want to use this pulse to drive a servo motor, with speed control (frequency of the pulse) and rotation control (number of pulses). Which I believe not possible with PWM generation, So I was trying to figure out a combination of PWM and interrupt. At the same time, our max pulse frequency requirement is 200KHz, which is not possible with timer interrupt. Please correct me. And if you have any solution, May I request you to share ? Thanks |
|
|
|
|
|
如果你不理睬我的问题,就没有帮助。
以上来自于百度翻译 以下为原文 If you just ignore my questions there's no point trying to help. |
|
|
|
|
|
我并没有忽视,我只是试图回答你的问题。我试图使用定时器0来生成脉冲,但是那些配置位在发送代码时没有注释。这就是为什么我说,忽略计时器0配置位。
以上来自于百度翻译 以下为原文 I am not ignoring, I am trying to answer your question only. I was trying to use Timer 0 to generate pulse, but those config bits were not commented while send you the code. that is why I said, ignore Timer 0 config bits. |
|
|
|
|
|
|
|
|
|
|
|
我能用20MHz的晶体PIC18F45 50产生200 kHz脉冲,并计数脉冲数吗?
以上来自于百度翻译 以下为原文 Can I generate 200KHz pulse with PIC18F4550 with 20MHz crystal, With counting the number of pulse? |
|
|
|
|
|
我认为你是运行在32 MHz的FoSC,所以8MHz的指令周期。8M/200K=40个指令每脉冲,因此使用计时器产生200kHz脉冲将使用几乎所有的处理器周期。也许您应该考虑使用CCP模块在PWM模式下生成脉冲而不涉及软件。
以上来自于百度翻译 以下为原文 I think you are running at 32MHz Fosc, so 8MHz instruction cycle. 8M/200K = 40 instructions per pulse, so using a timer to generate 200KHz pulses is going to use pretty much all of the processor cycles. Probably you should consider using a CCP module in PWM mode to generate the pulses without software involvement. |
|
|
|
|
|
谢谢你的夸奖。我说服自己,200K是困难的PIC18F45 50。
以上来自于百度翻译 以下为原文 Thanks mbrowning. I convince myself that 200K is difficult with PIC18F4550. |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475 浏览 0 评论
5794 浏览 9 评论
2334 浏览 8 评论
2224 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3530 浏览 3 评论
1124浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1098浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
873浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 13:50 , Processed in 1.548063 second(s), Total 93, Slave 76 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
594