[En-Nut-Discussion] UART_SETCLOCKMODE - UART_NSYNCSLAVE

Dave Smart Dave at Smart-Family.net
Mon Sep 11 13:58:33 CEST 2006


After searching the archives, I couldn't find the help I need. So, I hope
someone in this forum has been down this road before me.

I'm trying to use synchronous mode to receive data from a PC keyboard. I had
this working in early 2003 (before sync mode was natively supported), but
now I'm trying again with the latest tool chain. Hardware is an Ethernut 2.

It seems that whether I use UART_NSYNCSLAVE or UART_SYNCSLAVE, the data I
receive is always the same (as if that setting isn't working). Any ideas?

// Initialization
	FILE * uartkybd;
	int rlen = 0;
	u_long _ioctlParam;			// one parameter to save
stack frame
	
	// Sync UART Interface to PC Keyboard, which will retrieve Scan
Codes
	rlen = NutRegisterDevice(&devUart1, 0, 0);	// open the UART as
a stream
	uartkybd = fopen("uart1", "r+b");

      // Replace the standard Rx ISR with our custom version to do Scancodes
	rlen = NutRegisterIrqHandler(&sig_UART1_RECV, CustomRxComplete,
&devUart1);
	_ioctlParam = UART_NSYNCSLAVE;	// tx on rising edge, rx on falling
edge
	_ioctl(_fileno(uartkybd), UART_SETCLOCKMODE, &_ioctlParam);
	_ioctlParam = 2;
	_ioctl(_fileno(uartkybd), UART_SETPARITY, &_ioctlParam);
	_ioctlParam = 1;
	_ioctl(_fileno(uartkybd), UART_SETSTOPBITS, &_ioctlParam);
	_ioctlParam = 8;
	_ioctl(_fileno(uartkybd), UART_SETDATABITS, &_ioctlParam);
	// doesn't work here either
	//_ioctlParam = UART_NSYNCSLAVE;	// tx on rising edge, rx on
falling edge
	//_ioctl(_fileno(uartkybd), UART_SETCLOCKMODE, &_ioctlParam);
...



static void CustomRxComplete(void *arg)
	{
	u_char data;
	static prog_char hexonly_fmt[] = "UDR: %02X\n";

#ifdef UDR1
    if(dev->dev_base)
        data = inp(UDR1);
    else
#endif
        data = inp(UDR);

	printf_P(hexonly_fmt, data);
...



Kind regards,
Dave Smart 




More information about the En-Nut-Discussion mailing list