大家好,在我的项目中,我使用的是一个DSPIC33 EP64 MC202,它运行良好,但是,我怀疑我做的事情是正确的。我想避免未来的惊喜。我不知道该怎么做
威廉希尔官方网站
和如何配置它。威廉希尔官方网站
:在图OSC1OSC2.JPG,在附件,是我的两个版本的振荡器的CRCUIT。在我的设计中,我使用了第一个版本,没有1M欧姆电阻。第二个版本是我认为正确的版本。CRISTAL是一个15MHz(15000 0H5M)的FiuSrave:最初,我做了一个配置,在一个分离的文件中,在没有外部振荡器的情况下启动:在初始化之后,我配置了我的设备,改变了振荡器的频率和ChsSe外部振荡器:疑惑:1)我的第一个问题是,一个是威廉希尔官方网站
的正确版本?2)我的代码是否正确?即使第二个版本是正确的版本?(记住我的代码是基于威廉希尔官方网站
的第一个版本,没有电阻器)任何帮助都将非常感激。
以上来自于百度翻译
以下为原文
Hello all,
In my project I'm using a dsPIC33EP64MC202, and it is working fine, however, I have a doubt if I'm doing things the right way. I want to avoid surprises in the future. I'm in doubt how to do the circuit and how to configure it.
Circuit:
In the figure osc1osc2.jpg, at the attachments, are my two versions of the oscilator's crcuit. In my design I used the first version, without the 1M ohm resistor. The second version, is the version that I believe is correct. The cristal is a 15MHz (15.000H5M)
Firware:
Ini
tially, I did a configuration, in a separated file, starting without the external oscillator:
// Select Internal FRC at POR
_FOSCSEL(FNOSC_FRC & IESO_OFF & PWMLOCK_OFF );
// Enable Clock Switching and Configure POSC in HS mode
_FOSC(FCKSM_CSECMD & OSCIOFNC_OFF & POSCMD_HS & IOL1WAY_OFF);
//Desliga o watchdog
_FWDT( FWDTEN_OFF )
//Ativa os pinos de debug EMUC2 e EMUD2 e deabilita os de JTAG.
_FICD( ICS_PGD2 & JTAGEN_OFF )
//Desabilita qualquer proteção de codigo para depuracao
_FGS( GWRP_OFF & GCP_OFF )
After that initialization, I configured my device and change the oscilator frequency and chosse external oscillator:
void oscilador_configuraOscilador(){
CLKDIVbits.PLLPRE = 1; // N1 - 2
CLKDIVbits.PLLPOST = 0; // (N2/2) - 1
PLLFBDbits.PLLDIV = 46; // M - 2
RCONbits.SWDTEN = 0;
// Torna o clock do sistema Fcy igual ao clock do periférico Fp.
CLKDIVbits.DOZE = 0x000;
CLKDIVbits.DOZEN = 0;
// Initiate Clock Switch to Primary Oscillator with PLL (NOSC=0b011)
__builtin_write_OSCCONH(0x03);
__builtin_write_OSCCONL(OSCCON | 0x01);
// Wait for Clock switch to occur
while (OSCCONbits.COSC!= 0b011);
// Wait for PLL to lock
while (OSCCONbits.LOCK!= 1);
}
Doubts:
1 ) My first question is, wich one is the correct version of the circuit?
2 ) Is my code correct ? Even if the second version is the correct version ? (Remembering that my code here was made based on the first version of the circuit, without the resistor)
Any help would be very appreciated.
With my best regards.
Daniel.
Attached Image(s)