View Single Post
Old 03-03-2008, 05:51 PM   #10
ajack
Nhập môn đệ tử
 
Tham gia ngày: Jan 2008
Bài gửi: 6
:
Code:
// Timer 1 initialize: Internal Cycle Clock, với period_value = 16000, internal cycle là 16MIPs
void init_Timer1 (unsigned int Period_Value)
{
	T1CONbits.TON = 0;		// Disable Timer
	T1CONbits.TCS = 0;		// Select internal instruction cycle clock 
	T1CONbits.TGATE = 0;	// Disable Gated Timer mode
	T1CONbits.TCKPS = 0b00;	// Select 1:1 Prescaler
	TMR1 = 0x00; 			// Clear timer register
	PR1 = Period_Value; 	// Load the period value, 
	IPC0bits.T1IP = 0x01;	// Set Timer 1 Interrupt Priority Level
	IFS0bits.T1IF = 0;		// Clear Timer 1 Interrupt Flag
	IEC0bits.T1IE = 1;		// Enable Timer1 interrupt
	T1CONbits.TON = 1;		// Start Timer
}
Không hiểu tại sao mà mình không tạo được interrupt 1ms, mà lâu hơn 1ms
ajack vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn