[PIC®/AVR®/dsPIC®产品] 辅助振荡器的问题

[复制链接]
1175|15
 楼主| llia 发表于 2022-11-5 22:06 | 显示全部楼层 |阅读模式

PIC24F16KA101的辅助振荡器SOSC作为RTCC的时钟源。
但是一直不振。用内部的LPRC没问题。
 楼主| llia 发表于 2022-11-6 14:09 | 显示全部楼层
然后将SOSC作为主时钟源,用示波器可以看出来振荡了。
 楼主| llia 发表于 2022-11-6 14:13 | 显示全部楼层
#pragma config BWRP = OFF               // Table Write Protect Boot (Boot segment may be written)
#pragma config BSS = OFF                // Boot segment Protect (No boot program Flash segment)

// FGS
#pragma config GWRP = OFF               // General Segment Code Flash Write Protection bit (General segment may be written)
#pragma config GCP = OFF                // General Segment Code Flash Code Protection bit (No protection)

// FOSCSEL
#pragma config FNOSC = FRCDIV           // Oscillator Select (8 MHz FRC oscillator with divide-by-N (FRCDIV))
#pragma config IESO = ON               // Internal External Switch Over bit (Internal External Switchover mode disabled (Two-Speed Start-up disabled))

// FOSC
#pragma config POSCMOD = NONE           // Primary Oscillator Configuration bits (Primary oscillator disabled)
#pragma config OSCIOFNC = ON            // CLKO Enable Configuration bit (CLKO output disabled; pin functions as port I/O)
#pragma config POSCFREQ = HS            // Primary Oscillator Frequency Range Configuration bits (Primary oscillator/external clock input frequency greater than 8 MHz)
#pragma config SOSCSEL = SOSCHP         // SOSC Power Selection Configuration bits (Secondary oscillator configured for high-power operation)
#pragma config FCKSM = CSECMD           // Clock Switching and Monitor Selection (Clock switching is enabled, Fail-Safe Clock Monitor is disabled)

// FWDT
#pragma config WDTPS = PS256            // Watchdog Timer Postscale Select bits (1:256)
#pragma config FWPSA = PR128            // WDT Prescaler (WDT prescaler ratio of 1:128)
#pragma config WINDIS = OFF             // Windowed Watchdog Timer Disable bit (Standard WDT selected; windowed WDT disabled)
#pragma config FWDTEN = OFF              // Watchdog Timer Enable bit (WDT enabled)

// FPOR
#pragma config BOREN = BOR3             // Brown-out Reset Enable bits (Brown-out Reset enabled in hardware; SBOREN bit disabled)
#pragma config PWRTEN = ON              // Power-up Timer Enable bit (PWRT enabled)
#pragma config I2C1SEL = PRI            // Alternate I2C1 Pin Mapping bit (Default location for SCL1/SDA1 pins)
#pragma config BORV = V18               // Brown-out Reset Voltage bits (Brown-out Reset set to lowest voltage (1.8V))
#pragma config MCLRE = ON               // MCLR Pin Enable bit (MCLR pin enabled; RA5 input pin disabled)

// FICD
#pragma config ICS = PGx1               // ICD Pin Placement Select bits (PGC1/PGD1 are used for programming and debugging the device)

// FDS
#pragma config DSWDTPS = DSWDTPS8       // Deep Sleep Watchdog Timer Postscale Select bits (1:131,072 (135 Seconds))
#pragma config DSWDTOSC = SOSC          // DSWDT Reference Clock Select bit (DSWDT uses SOSC as reference clock)
#pragma config RTCOSC = SOSC            // RTCC Reference Clock Select bit (RTCC uses SOSC as reference clock)
#pragma config DSBOREN = ON             // Deep Sleep Zero-Power BOR Enable bit (Deep Sleep BOR enabled in Deep Sleep)
#pragma config DSWDTEN = ON             // Deep Sleep Watchdog Timer Enable bit (DSWDT enabled)

代码就一个地方注意了
OSCCONbits.SOSCEN = 1;
llljh 发表于 2022-11-6 14:16 | 显示全部楼层
OSCCONbits.SOSCEN = 1;该位需要用解锁序列
wuhany 发表于 2022-11-6 14:24 | 显示全部楼层
有些型号是可以直接使能的
jiajs 发表于 2022-11-6 14:27 | 显示全部楼层
这个型号不知道为什么需要解锁
zhanghqi 发表于 2022-11-6 14:29 | 显示全部楼层
不起振的话,有可能是负载电容过大
dengdc 发表于 2022-11-6 14:36 | 显示全部楼层
主时钟是主时钟, 辅助时钟是辅助时钟,两个不一样的, 你要研究一下
tpgf 发表于 2022-12-5 14:50 | 显示全部楼层
是不是只有微芯的芯片里边才有辅助振荡器呢呀
nawu 发表于 2022-12-5 15:01 | 显示全部楼层
晶体不起作用,晶体断裂,晶体质量不正确,连接不好,连接短路,错误引脚和类似的不太可能的错误
aoyi 发表于 2022-12-5 16:20 | 显示全部楼层
试着检查定时器1是否会在启用定时器1振荡器的情况下运行:或者尝试您已经拥有的代码作为注释
zljiu 发表于 2022-12-5 16:32 | 显示全部楼层
如果在调试器中运行和停止程序,如果TMR1L或TMR1H寄存器发生更改,请与调试器进行检查。
gwsan 发表于 2022-12-5 16:45 | 显示全部楼层
振荡器的低功率设置是非常低的驱动电平,并且可能是挑剔的
tfqi 发表于 2022-12-5 17:06 | 显示全部楼层
尝试使用γ-PrimaMac配置LPT1OSC=OFF为PrimaPrimaMatrg LPT1OSC1
小夏天的大西瓜 发表于 2022-12-25 12:17 | 显示全部楼层
是不是直接使用啊?还是需要解锁
OKAKAKO 发表于 2022-12-25 13:24 | 显示全部楼层
应该是设置问题,建议楼主再查看一下手册看看RTCC时钟电源是不是需要设置
您需要登录后才可以回帖 登录 | 注册

本版积分规则

961

主题

8893

帖子

4

粉丝
快速回复 在线客服 返回列表 返回顶部