我试图从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 selec
ting 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
0