完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我试图从16F526切换到一些工作代码到16F150 3。当选择外部时钟引脚时,它不会正常工作。我清除TMR0,延迟1ms(硬编码循环),然后存储TMR0。信号是48千赫或96kHz,我正在破译,并采取适当的行动。当我用芯片焊接到板上并使用ICSP时,我不能直接调试。因此,在获得TMR0值之后,我插入代码来摆动一个未使用的引脚,将一个索引设置向下计数为TMR0值。无论我使用的内部时钟的时钟速度如何,在尝试所有不同的预分频器值或没有预分频器时,总是会看到大约255个脉冲。然后我禁用输入信号,它仍然报告回来255!运行在MPLAB SIM中,它给出了预期的零(没有使用刺激文件)。我用汇编写,这里是安装代码:这里是测量的片段:
以上来自于百度翻译 以下为原文 I'm trying to switch from a 16F526 with some working code to a 16F1503. It seems when selecting the external clock pin, it won't work right. I clear TMR0, delay 1mS (hard coded loop), then store TMR0. The signal is either 48kHz or 96kHz and I'm deciphering which and taking appropriate action. As I'm working with the chip soldered to a board and using ICSP, I can't debug directly. So After getting the TMR0 value I inserted code to wiggle an unused pin counting down an index set to the TMR0 value. No matter what clock speed off the internal clock I use, there are always about 255 pulses seen and the same when trying all different prescaler values or no prescaler at all. Then I disabled the input signal and it still reports back 255! Running in MPLAB SIM, it gives zero as expected (no stimulus file is used). I write in assembly and here is the setup code: ORG 0x00 ;program starts at ROM loc 0x000 start BANKSEL ANSELC ;BANK 3 clrf ANSELC clrf ANSELA BANKSEL PORTC ;BANK 0 movlw b'00000001' ;pin 0 to keep mute on until power on delay movwf PORTC ;set up port A movlw b'00011011' ;pin 2 is unused and set as an output BANKSEL TRISA ;BANK 1 movwf TRISA ;set port direction ;set up port C movlw b'00100000' movwf TRISC ;set port direction as outputs except pin 5 ;Timer 0 set up. Bits are in the OPTION register movlw b'11110000' ;lowest prescale of 1:2 and assigned to Timer 0 movwf OPTION_REG movlw b'01110000' movwf OSCCON BANKSEL 0 ;BANK 0 to run code now Here is a snippet of doing the measurement: clrf TMR0 ;clear counter call dly1m ;counting time movf TMR0,W ;get the count of LR cycles movwf cntLR ; DEBUG stuff ;movlw 0x05 ;movwf cntLR lpGF bsf PORTA,5 bcf PORTA,5 decfsz cntLR goto lpGF |
|
相关推荐
2个回答
|
|
你确定它给出了255个,而不是256个脉冲(TMR=0会给出256)。你应该使用LATA,而不是使用BSF和BCF指令的PATA。“外部时钟引脚”是T0CKI,这是RA2。你说这是未用的,并且被设置为输出。
以上来自于百度翻译 以下为原文 Are you sure it's giving 255, and not 256 pulses (TMR=0 would give 256). You really should be using LATA, not PORTA with the BSF and BCF instructions. The "external clock pin" is T0CKI, which is RA2. You say that is unused and set to an output. Which pin are you feeding the clock into? |
|
|
|
你把它钉死了!我认为T0CKI是与16F526相同的PIN,它不是,所以它不能工作,而不是从引脚4(QFN)重新路由跟踪,这是RC5到PIN 10,它是RA2需要的地方。谢谢你的帮助。
以上来自于百度翻译 以下为原文 You just nailed it! I thought the T0CKI was on the same pin as the 16F526 and it's not, so it can't work without rerouting the trace from pin 4 (QFN) which is RC5 to pin 10 which is RA2 where it needs to be. Thanks for taking a look and assisting. |
|
|
|
只有小组成员才能发言,加入小组>>
5137 浏览 9 评论
1987 浏览 8 评论
1917 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3157 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2215 浏览 5 评论
705浏览 1评论
595浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
479浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
609浏览 0评论
504浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-6 23:25 , Processed in 1.105198 second(s), Total 48, Slave 41 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号