[En-Nut-Discussion] Using USART to Rx from PC Keyboard
Dave Smart
SmartFamily at mchsi.com
Mon Dec 30 18:09:51 CET 2002
Hi Harald,
Just to be in the request queue, I'm hoping that your new driver will
support the synchronous mode of the built-in USARTs.
As you may recall, I was having some problems with the sync mode. I haven't
proved the cause, but I have it working now based on the 2.5.2 code base.
What I changed from my earlier post of the code was relatively minor, and I
need to back the change out to verify that it then fails - thus proving the
change.
Surrounding each UartAvrSet<feature> modification, I disabled and then
enabled the USART. Here is one example, and note that I only applied this to
receiver of UART1, since that was the port I was using -
/*
* \param parm Zero sets async, One sets Sync mode
*
* \param dev Indicates the UART device.
*
* \return 0 on success, -1 otherwise.
*/
static int UartAvrSetSync(UARTDCB *dcb, u_long parm, u_char devnum)
{
u_char bits = (parm & 1) << 6; // Position to 0x40
#ifdef UCSR1C
if (devnum)
{
UCSR1B &= ~0x10; // disable receiver
UCSR1C = (UCSR1C & ~0x40) | bits;
UCSR1B |= 0x10; // enable receiver
}
else
#endif
UCSR0C = (UCSR0C & ~0x40) | bits;
return 0;
}
Like I say, I haven't proven that to be the solution, and I didn't find
anything in the manual to support this, but it is now working for me.
kind regards,
Dave Smart
More information about the En-Nut-Discussion
mailing list