Trích:
Nguyên văn bởi ajack
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
|
Mức độ lâu hơn ra sao: lâu hơn một chút, hay gấp đôi, gấp ba, hay nhiều hơn nữa? Bạn dựa vào đâu để cho rằng dsPIC chạy ở 16 MIPS?
Thân,