im working with Timer1 in dsPIC30F4011 and i have a problem when
i want using this timer to generating 1us delay,
i couldnt generate below 18.8us with this timer
im decrease PR1 to 4 but its not work
this is my codes:
Code: Select all
void Timer1Int() org 0x1A // Timer1 address in the interrupt vector table
{
// Place your codes here-------------------
LATD = ~PORTD; // PORTD inversion
//-----------------------------------------
IFS0 = IFS0 & 0xFFF7; // Interrupt flag reset
}
void timer1_init(void);
void main()
{
TRISD = 0x00; // PORTD is output
LATD = 0x00; // Set initial value at port D
//timer1_init();
while(1)
{
LATD = ~LATD; // PORTD inversion
};
}
void timer1_init(void)
{
T1CON = 0x0000; // Stops the Timer1 and reset control reg
TMR1 = 0x0000; // Clear contents of the timer register
PR1 = 4; // Load the Period register with desired value
IPC0 = IPC0 | 0x1000; // Priority level is 1
IFS0 = IFS0 & 0xFFF7; // Interrupt flag reset
IEC0 = IEC0 | 0x0008; // Timer1 interrupt enabled
T1CON = 0x8000; // Timer1 enabled (internal clock divided by 1 & FOSC/4)
}