完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好,我目前正试图通过调整OSCTUNE值来校准PIC18F24K50,因为当它来自工厂时,似乎有一个相当宽的可接受范围或公差。几周后,我终于找到了一个频率校准例程,无法写入OSCTUNK寄存器。该程序目前非常简单和活跃的时钟调谐(通过ACTCON寄存器)已禁用通过上电复位。我明白,如果启用了激活的时钟调整,则无法修改OSCOUNT值。我已经尝试了所有我能想到的,包括在写到OSCTUNE寄存器之前把BSR设置成存储的SFR,虽然我通常更喜欢我在示例代码中使用的方法(即MOVWF OSCTUNE,Access,以减少代码大小)。按钮输入,然后确定上下按钮是否被按下。然后,显示当前的OSCOUNT值,增减OSCTUNK寄存器,将两个补码的OSCORT值转换为其十进制正负等价,并在LCD屏幕上显示变化,最后显示新更新的OSCOTE值的值。它回去检查额外的按钮输入。我一直在使用PIC输出一个1赫兹方波,它会连接到示波器上,然后按下上下按钮来调整它与被测的相应。但是它不起作用,因为即使在启动按钮循环之前改变OSCORT值,它也是ALWA。YES读取为零,任何变化都没有反映在我以前尝试过的1赫兹输出回路中。这样做是因为将其他PIC连接到这一个,在这里我尝试得到最快的无错误通信。但是,工厂校准的内部振荡器的公差给了我一些导致校准过程的问题。(是的,还有第二个步骤,其中连接的其他PIC被校准为这个“主”。)不,没有列出子例程的任何代码,因为我以前在代码的其他部分使用过它们,并且没有任何问题。只是OSCTUNE的问题。它目前正在使用3.3伏的电压调节器从5伏USB连接(USB目前没有使用或启用在这个调试过程)。任何人都有类似的问题,不能改变OcCon值。我已经阅读了整个OSCTUNE部分,甚至ACTCON部分,但没有找到任何帮助。可能错过了一些东西,但我在这里,因为我无法计算出这一个。对不起,代码部分,我总是不可能让它看起来很好的论坛。:(
以上来自于百度翻译 以下为原文 Hello all, I am currently attempting to be able to calibrate a PIC18F24K50 by adjusting the OSCTUNE value because there seems to be a fairly wide acceptable range or tolerance when it comes from the factory. It has been a few weeks and finally tracked down my problem in writing a frequency calibration routine to me unable to write to the OSCTUNE register. The program is currently very simple and Active Clock Tuning (via ACTCON Register) is already disabled via power on reset. I understand that if Active Clock Tuning is enabled, you are unable to modify the OSCTUNE value. I've tried everything that I can think of, including setting BSR to banked SFRs before writing to the OSCTUNE register though I normally prefer the method that I've used in the example code (i.e. MOVWF OSCTUNE, ACCESS in order to reduce code size). MAIN MOVLB 0xF ; Point to Bank #15 (SFR Location) CLRF ANSELA ; Configure I/O for Digital I/O (Port B Disabled in CONFIG Settings) CLRF ANSELB ; NEEDED? CLRF ANSELC ; ----- NOTE: Need to Leave RB<2> Digital Input for INT2 Interrupt CLRF LATA ; Clear Output Data Latches CLRF LATB ; | CLRF LATC ; ----- CLRF TRISA MOVLW 0x06 ; | Turn Off Digital Output Drivers @ RB<2> Push-Button Analog Input MOVWF TRISB ; ----- & RB<1> RTC MFP Input for 1 Hz Clock Pulse (Falling Edge) MOVLW b'01110101' ; Enable TMR2 Peripheral Module MOVWF PMD0 ; (CCP1 Module Clock Source = TMR2) MOVLW b'01111110' ; Enable CCP1 Peripheral Module MOVWF PMD1 ; (LCD Backlight Intensity Control) MOVLW 0x77 ; Set-Up PWM of CCP1 Module for LCD Backlight Intenisty Control (95%) MOVWF PR2 ; | Set PWM Period Value MOVLW 0x3C ; | Load Value to: MOVWF CCP1CON ; | Set PWM Mode & LSbs of PWM Duty Cycle MOVLW 0x71 ; | Load Value to: 95% MOVWF CCPR1L ; | Set MSbs of PWM Duty Cycle CLRF T2CON ; | Post-Scaler = 1:1, Pre-Scaler = 1:1, Timer2 = Off BSF T2CON,2 ; ----- Enable (Turn On) Timer #2 CLRF TRISC ; Set Port C Pins to Output, Enable Output Driver to Start PWM Output CLRF TMR0H ; Set-Up Timer #0, 1st Clear 16-Bit Timer Registers CLRF TMR0L ; | MOVLW 0x01 ; Set-Up Timer #0 for 1:256 Pre-Scale CURRENT 1:4 MOVWF T0CON ; ----- BSF OSCCON,7,ACCESS ; Set OSCCON,IDLEN to Enter Idle on SLEEP Instruction CLRF BSR ; Point Back to BANK #0 CALL LCD_CLR PUT_TEXT "CALIBRATION MODE ON:" CHK_LUP BTFSC PORTB,2,ACCESS ; Push-Button Pressed??? CALL DeBounce TSTFSZ Button CALL OSC_ADJ BRA CHK_LUP OSC_ADJ CALL LCD_LN2 MOVF OSCTUNE,W,ACCESS ; W_TEMP = Current OSCTUNE Value ANDLW b'01111111' ; Remove Bit #7 (PLL Selector Bit: 3X vs. 4X) MOVWF W_TEMP ; ----- CALL DigByte ; Display Old OSCTUNE Value MOVLW ' ' CALL LCD_CHR BTFSC Button,UP ; UP Push-Button Pressed? BRA INC_OSC ; Yes, INCREASE OSCTUNE by 1 & RETURN to 1 Hz Loop ; BTFSC Button,SEL ; SEL Push-Button Pressed? ; BRA SAVE_OSC ; Yes, SAVE OSCTUNE to EEPROM (0xF0) & Enter STEP #2 BTFSC Button,DN ; DN Push-Button Pressed? BRA DEC_OSC ; Yes, DECREASE OSCTUNE by 1 & RETURN to 5 kHz LOOP BRA LUP_ENT ; No, Just Noise, Re-Enter 1 Hz Output Calibration Loop INC_OSC INCF W_TEMP,F ; W_TEMP = W_TEMP + 1 BRA PvN_CHK ; Is Total Adjustment +'ve or -'ve? DEC_OSC DECF W_TEMP,F ; W_TEMP = W_TEMP + 1 BCF W_TEMP,7 ; Make Sure Bit #7 is Clear (When Decreasing from 0) PvN_CHK MOVFF W_TEMP,OSCTUNE ; No, All Good, Update OSCTUNE & Dispaly Value BTFSS W_TEMP,6 ; Check Negative (Two's-Complement) BRA POS ; No, Positive, Display "+" NEG MOVLW '-' ; Display "-", Convert Two's-Complement CALL LCD_CHR ; & Display Value on LCD Screen COMF W_TEMP,W ; Move New OSCTUNE Value to W & Convert Two's-Complement Value BCF WREG,7 ; Remove Bit #7 (Not Used) & Messes Up Result ADDLW .1 ; ----- D_VALUE CALL DigByte ; Convert Updated OSCTUNE Value & Display as Decimal MOVF OSCTUNE,W,ACCESS CALL DigByte LUP_ENT CLRF Button ; Clear Button Variable & Then RETURN ; RETURN to Push-Button Input Check POS MOVLW '+' ; Display "+" & Display Value CALL LCD_CHR ; on LCD Screen MOVF W_TEMP,W ; W = W_TEMP = Updated OSCTUNE Value BRA D_VALUE ; Display the Value What is supposed to happen is that it scans my two push-buttons for input and then determines if the up or down button is pressed. After that it displays the current OSCTUNE value, increases or decreases the OSCTUNE register, converts the two's complement OSCTUNE value to it's decimal positive or negative equivalent and display the change on the LCD screen and finally display the value of the newly updated OSCTUNE value before it goes back to check for additional Push-Button input. I had been using the PIC to output a 1 Hz square wave that would be connected to an oscilloscope and then pressing the up or down button to adjust it accordingly to what is measured. It doesn't work, however, because even if I change the OSCTUNE value before starting the push-button loop, it is always read as ZERO and any changes are not reflected in the 1 Hz output loop that I had tried before. Doing this due to connecting other PICs to this one where I'm trying to get the fastest error free communication that I can. But, the tolerance in the factory calibrated internal oscillator has given me some problems leading to this calibration process. (And, yes, there is a second step where the other PICs connected are calibrated to this "Master".) No, didn't list any of the code for the sub-routines because I've used them all before in other sections of code and don't have any trouble with it. Just the OSCTUNE issue. It's currently running off of 3.3 volts using a voltage regulator from a 5 volt u*** connection (USB is not currently used or enabled during this debugging process). Anyone have any similar issue with not being able to change the OCTUNE value. I've read the whole OSCTUNE section and even the ACTCON section but haven't found anything that helps. May have missed something but I'm here because I cannot figure this one out. Sorry about the code section, it's always impossible for me to get it to look great on the forum. :( |
|
相关推荐
8个回答
|
|
|
|
|
|
表示必须禁用ACT模块,然后在更新OSCTUNE之前等待3条指令。
以上来自于百度翻译 以下为原文 Says you have to disable the ACT module then wait 3 instructions before updating OSCTUNE. |
|
|
|
它位于RAM库0 @ 0x60。我忘了提到我正在使用可重新定位的代码,因为最终版本将使用USB通信来更新这种类型的PIC上的“程序”。伟大的一点,但应该检查使用一个不同的变量,以及看看是否改变任何东西。我一直在使用WYTEMP作为低优先级中断的上下文保存变量,但在这种情况下,它不应该跳到中断,因为中断现在是禁用的。中断服务程序的上下文变量SaveIn将尝试使用不同的变量,即使我认为这不会有帮助……也不会影响尝试。
以上来自于百度翻译 以下为原文 It's located in RAM bank 0 @ 0x60. I did forget to mention that I'm using relocatable code because the final version will be using USB communication to update "programs" on this type of PIC. Great point though, should check using a different variable as well and see if that changes anything. I had been using w_temp as a context-saving variable for a low-priority interrupt but in this case it should never even jump to an interrupt since interrupts are disabled now. MainVars2 UDATA 0x60 ; ============================================================ ; ===== Program Specific Variables ====================================== W_TEMP RES 1 ; Variables for Interrupt Service Routine Context Saving Will attempt using a different variable even though I don't think that will help...doesn't hurt to try. |
|
|
|
谢谢你的建议。我不使用USB和活动时钟调整模块,并通过在初始化阶段写0x75或B’01110101’来设置PMD0寄存器中的位来确保它们被关闭。我想,如果激活的时钟调整模块实际上启用了,您的建议只需要,对吧?
以上来自于百度翻译 以下为原文 Thank you for the suggestion. I am not using the USB and Active Clock Tuning modules and made sure they were off by setting the bits in the PMD0 register by writing 0x75 or b'01110101' to it during my initialization phase. I would think that what you suggested would only be required if Active Clock Tuning module was actually enabled, right? |
|
|
|
是的,切换到一个不同的变量是不起作用的,写在OSCTUNE上的任何东西都是不粘的,而OSCOUNT只读取相同的0x00,无论写入的是什么。已使用MOVFF、CIFF、DECF、MOVWF -& GT;没有更新OSCTUNE寄存器。
以上来自于百度翻译 以下为原文 Yes, switching to a different variable doesn't work, whatever is written to OSCTUNE does not stick, and OSCTUNE reads only equal 0x00 no mater what is written. Have used MOVFF, INCF, DECF, MOVWF --> nothing updates the OSCTUNE register. |
|
|
|
是的,但它是一个在启用时更新OSCTUNE的模块。当禁用时,你可以写。你肯定没有读过另一种方法吗?别忘了3个NOP。
以上来自于百度翻译 以下为原文 Yes but it is a module that updates osctune when enabled. When disabled you can write. Sure you haven't read it the other way? Don't forget the 3 nops. |
|
|
|
你使用CPU时钟的源代码(你没有在代码中显示)。
以上来自于百度翻译 以下为原文 What source are you using for the cpu clock (you did not show this in your code). |
|
|
|
内部振荡器以默认的1 MHz速度运行。在我的开发源代码中,当一个程序(包括高速PIC到PIC通信发生)运行时,我使用内部振荡器和3X PLL切换到48 MHz,否则它将是默认的1 MHz内部振荡器。有源时钟调谐仅用于连接到USB通过PC程序更新,我已经测试和工作惊人。编辑二次速度设置,已经说过32兆赫,但是48兆赫(其他连接的速度是32兆赫)。
以上来自于百度翻译 以下为原文 Internal oscillator running at the default 1 MHz speed. In my development source code, I switch to 48 MHz using the internal oscillator and the 3X PLL for times when a program (including the high speed PIC to PIC communication happens) is running Otherwise it's all the default 1 MHz internal oscillator. Active clock tuning is only used if connected to USB for program updates via PC which I have tested and works fabulous. Edited secondary speed setting, had said 32 MHz, but is 48 MHz (the speed of the other PICs connected are 32 MHz). |
|
|
|
只有小组成员才能发言,加入小组>>
5237 浏览 9 评论
2026 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3201 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
772浏览 1评论
662浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
590浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
672浏览 0评论
572浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-21 15:37 , Processed in 1.410632 second(s), Total 90, Slave 74 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号