[En-Nut-Discussion] AT91SAM7X-EK, UART messing up the NutSleep
Jix Electronics
jix.electronics at mbnet.fi
Sat Jul 22 13:33:43 CEST 2006
Hi,
I run to problems with uart, seems that devices DEV_UART and DEV_DEBUG
does not
work properly, tested with version 4.1.9-rc5.
When example code (below) is compiled with DEV_UART device. The first
NutSleep
call works correctly before registering the device. Second NutSleep waits
just
zero ticks, after that seems to work correctly.
example code print output:
(10)start=0, stop=10 --> 10
(10)start=41, stop=41 --> 0
(5)start=41, stop=46 --> 5
(1)start=46, stop=47 --> 1
When example code is compiled with DEV_DEBUG device, the first NutSleep works
correctly. All NutSleep calls after registering the device waits less than
asked for.
example code print output:
(10)start=0, stop=10 --> 10
(10)start=12, stop=20 --> 8
(5)start=22, stop=25 --> 3
(1)start=27, stop=27 --> 0
Modified threads example code
-----------------------------
int main(void)
{
u_long baud = 115200;
u_long start;
u_long stop;
start = NutGetTickCount();
NutSleep(10);
stop = NutGetTickCount();
/*
* Register the UART device, open it, assign stdout to it and set
* the baudrate.
*/
NutRegisterDevice(&DEV_DEBUG, 0, 0);
freopen(DEV_DEBUG_NAME, "w", stdout);
_ioctl(_fileno(stdout), UART_SETSPEED, &baud);
printf("\n(10)start=%lu, stop=%lu\t--> %lu", start, stop, stop-start);
start = NutGetTickCount();
NutSleep(10);
stop = NutGetTickCount();
printf("\n(10)start=%lu, stop=%lu\t--> %lu", start, stop, stop-start);
start = NutGetTickCount();
NutSleep(5);
stop = NutGetTickCount();
printf("\n(5)start=%lu, stop=%lu\t--> %lu", start, stop, stop-start);
start = NutGetTickCount();
NutSleep(1);
stop = NutGetTickCount();
printf("\n(1)start=%lu, stop=%lu\t--> %lu", start, stop, stop-start);
/*
* Start two additional threads. All threads are started with
* priority 64.
*/
NutThreadCreate("t1", Thread1, 0, 512);
NutThreadCreate("t2", Thread2, 0, 512);
putchar('\n');
putchar('\n');
putchar('\r');
/*
* Endless loop in main thread.
*/
for (;;) {
putchar('M');
NutSleep(125);
}
}
Jix
More information about the En-Nut-Discussion
mailing list