We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi,
I am using MCB2300 board with LPC2387. I want to toggle my LEDs with delay from 20 to 30 microsecond. I found function for delay in millisecond and microsecond from its sample code. below is the function for microsecond.
void delayus(BYTE timer_num, DWORD delayInus) { if ( timer_num == 0 ) { /* * setup timer #0 for delay */ T0TCR = 0x02; /* reset timer */ T0PR = 0x00; /* set prescaler to zero */ T0MR0 = delayInus * (Fpclk - 1); T0IR = 0xff; /* reset all interrrupts */ T0MCR = 0x04; /* stop timer on match */ T0TCR = 0x01; /* start timer */ /* wait until delay time has elapsed */ while (T0TCR & 0x01); }
Below is the function of millisecond.
void delayMs(BYTE timer_num, DWORD delayInMs) { if ( timer_num == 0 ) { /* * setup timer #0 for delay */ T0TCR = 0x02; /* reset timer */ T0PR = 0x00; /* set prescaler to zero */ T0MR0 = delayInMs * (Fpclk / 1000-1); T0IR = 0xff; /* reset all interrrupts */ T0MCR = 0x04; /* stop timer on match */ T0TCR = 0x01; /* start timer */ /* wait until delay time has elapsed */ while (T0TCR & 0x01); }
the problem is when I use delay function of Microsecond in main function for delay, I write delayus(0,20) for delay of 20 Microsecond But led blinks at every 20 seconds instead of every 20 Microsecond.
So I think this function is work for delay of second not for Microsecond.
while the function of Millisecond is working properly.
So let me know am i doing something wrong?
Thanks
Hi per,
Sorry for wrong answer....