Ðề tài: code mau!
View Single Post
Old 04-11-2009, 01:46 AM   #1
tungnh
Đệ tử 5 túi
 
Tham gia ngày: Sep 2007
Bài gửi: 94
:
Code:
#include "p33FJ256GP710.h"
_FOSCSEL(FNOSC_PRIPLL);			// Primary (XT, HS, EC) Oscillator with PLL
_FOSC(FCKSM_CSDCMD & OSCIOFNC_OFF  & POSCMD_XT); 
_FWDT(FWDTEN_OFF);              
_FGS(GCP_OFF);            		
int i;
int main(void)
{
					// Configure Oscillator to operate the device at 40Mhz
					// Fosc= Fin*M/(N1*N2), Fcy=Fosc/2
					// Fosc= 10M*32/(2*2)=80Mhz for 10M input clock
	PLLFBD=30;					// M=32
	CLKDIVbits.PLLPOST=0;		// N1=2
	CLKDIVbits.PLLPRE=0;		// N2=2
	OSCTUN=0;					// Tune FRC oscillator, if FRC is used
								// Disable Watch Dog Timer
	RCONbits.SWDTEN=0;
								// Wait for PLL to lock
	PSVPAG = 0;
	CORCONbits.PSV=1;
	__builtin_write_OSCCONH(0x03);		// Initiate Clock Switch to Primary
								// Oscillator with PLL (NOSC=0b011)
	__builtin_write_OSCCONL(0x01);		// Start clock switching
	while (OSCCONbits.COSC != 0b011);	// Wait for Clock switch to occur
	while(OSCCONbits.LOCK!=1) {};
	TRISD = 0;
         while(1)
         {
            LATD++;
           for(i=0;i<65000;i++);
           for(i=0;i<65000;i++);
         }
}
bạn có thể đo câc chân ở cổng D , bạn sẽ thấy độ rộng xung tăng dần từ D0->D15
tungnh vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn