Dwayne Dietrich

Coldfire Auto RTS toggle

Discussion created by Dwayne Dietrich Employee on Apr 1, 2006
This message contains an entire topic ported from the WildRice - Coldfire forum.  Freescale has received the approval from the WildRice administrator on seeding the Freescale forum with messages.  The original message and all replies are in this single message. We have seeded this new forum with selected information that we expect will be of value as you search for answers to your questions.  Freescale assumes no responsibility whatsoever with respect to Posted Material.  For additional information, please see the Terms of Use - Message Boards and Community Forums.  Thank You and Enjoy the Forum!
 

Dec 12, 2005, 10:49 AM
Post #1 of 7 (53 views)
Copy Shortcut
 [ColdFire] Coldfire Auto RTS toggle  Can't Post 
--------------------------------------------------------------------------------
 
I'm having trouble getting the RTS auto toggle functionality of the Coldfire
to work correctly.
Using debug statements I have verified that I am setting
UMR1 = 0x13 (Rx RTS off)
UMR2 = 0x27 (Tx RTS on)
Before transmitting data, I enable RTS (setting the output pin low by writing
1 to UOP1)
After transmitting the processor generates an interrupt and the status
register reads
USR=c (Indicating the transmitter is empty and ready)
At this point, as I understand it, the RTS line should have automatically
toggled off, but it doesn't.
I can move it manually with the UOP registers, but this automatic toggle
feature is not working for me.
Has anyone else been down this road?
Any suggestions?
thank you,
NZG
 
 
--------------------------------------------------------------------
Dec 12, 2005, 11:13 AM
Post #2 of 7 (53 views)
Copy Shortcut
 Re: [ColdFire] Coldfire Auto RTS toggle [In reply to]  Can't Post 
--------------------------------------------------------------------------------
 
Hmmm...
I experienced a similar problem with RTS on the 5282. I've also heard
that some 5272 users are experiencing the same problem and that (maybe)
Freescale has released an errata acknowledging the problem (don't take
my word on that).
What proc are you using?

Aaron Shepard

NZG wrote:
>I'm having trouble getting the RTS auto toggle functionality of the Coldfire
>to work correctly.
>
>Using debug statements I have verified that I am setting
>UMR1 = 0x13 (Rx RTS off)
>UMR2 = 0x27 (Tx RTS on)
>
>Before transmitting data, I enable RTS (setting the output pin low by writing
>1 to UOP1)
>After transmitting the processor generates an interrupt and the status
>register reads
>USR=c (Indicating the transmitter is empty and ready)
>
>At this point, as I understand it, the RTS line should have automatically
>toggled off, but it doesn't.
>
>I can move it manually with the UOP registers, but this automatic toggle
>feature is not working for me.
>
>Has anyone else been down this road?
>Any suggestions?
>
>thank you,
>NZG
>

--------------------------------------------------------------------
Dec 12, 2005, 11:24 AM
Post #3 of 7 (53 views)
Copy Shortcut
 Re: [ColdFire] Coldfire Auto RTS toggle [In reply to]  Can't Post 
--------------------------------------------------------------------------------
 
On Monday 12 December 2005 1:13 pm, Aaron Shepard wrote:
> Hmmm...
>
> I experienced a similar problem with RTS on the 5282. I've also heard
> that some 5272 users are experiencing the same problem and that (maybe)
> Freescale has released an errata acknowledging the problem (don't take
> my word on that).
>
> What proc are you using?
The 5282.
I just noticed something in the manual about disabling the transmitter.
I'm going to try that and see if anything different happens.
I'll let you know
NZG
 
 
>
> Aaron Shepard
>
> NZG wrote:
> >I'm having trouble getting the RTS auto toggle functionality of the
> > Coldfire to work correctly.
> >
> >Using debug statements I have verified that I am setting
> >UMR1 = 0x13 (Rx RTS off)
> >UMR2 = 0x27 (Tx RTS on)
> >
> >Before transmitting data, I enable RTS (setting the output pin low by
> > writing 1 to UOP1)
> >After transmitting the processor generates an interrupt and the status
> >register reads
> >USR=c (Indicating the transmitter is empty and ready)
> >
> >At this point, as I understand it, the RTS line should have automatically
> >toggled off, but it doesn't.
> >
> >I can move it manually with the UOP registers, but this automatic toggle
> >feature is not working for me.
> >
> >Has anyone else been down this road?
> >Any suggestions?
> >
> >thank you,
> >NZG
> >
> >
> >
> >
> >
> >--------------------------------------------------------------------

--------------------------------------------------------------------
Dec 12, 2005, 11:53 AM
Post #4 of 7 (53 views)
Copy Shortcut
 Re: [ColdFire] Coldfire Auto RTS toggle [In reply to]  Can't Post 
--------------------------------------------------------------------------------
 
> > >I'm having trouble getting the RTS auto toggle functionality of the
> > > Coldfire to work correctly.
> > I experienced a similar problem with RTS on the 5282. I've also heard
> > that some 5272 users are experiencing the same problem and that (maybe)
> > Freescale has released an errata acknowledging the problem (don't take
> > my word on that).
>
> The 5282.
> I just noticed something in the manual about disabling the transmitter.
> I'm going to try that and see if anything different happens.
> I'll let you know
This does appear to be the missing piece of the puzzle. After disabling the
transmitter the UART finished it's final transmission, and the RTS line did
move.
Now I just need to work a clean enable/disable system into my code and I
should be in business. I'll keep you posted.
NZG.

--------------------------------------------------------------------
Dec 13, 2005, 7:30 AM
Post #5 of 7 (51 views)
Copy Shortcut
 Re: [ColdFire] Coldfire Auto RTS toggle [In reply to]  Can't Post 
--------------------------------------------------------------------------------
 
If you don't mind me asking, what was your exact procedure? For
example: Set nRTS, drop a char into the tx buffer, monitor TxEMPTY,
disable transmitter, etc.
For us, turning off the transmitter (with the TxRTS bit set) did not
negate the nRTS line.
Thanks,
Aaron Shepard
Harrison Audio
>The 5282.
>I just noticed something in the manual about disabling the transmitter.
>I'm going to try that and see if anything different happens.
>I'll let you know
>
>NZG
>
>
--------------------------------------------------------------------
Dec 13, 2005, 8:33 AM
Post #6 of 7 (46 views)
Copy Shortcut
 Re: [ColdFire] Coldfire Auto RTS toggle [In reply to]  Can't Post 
--------------------------------------------------------------------------------
 
Set nRTS, drop a char into the tx buffer, monitor TxEMPTY,
disable transmitter
That's pretty much it. Just have to make sure the TXRTS bit is set and the
RXRTS bit isn't.
A patch to the mcfserial driver for this, was posted the other day by Andrew
Kohlsmith to the uClinux mailing list.
--- mcfserial.c.before_trying_timer_mod 2005-11-20 12:13:51.000000000 -0500
+++ linux-2.4.x/drivers/char/mcfserial.c 2005-11-23 22:25:08.000000000 -0500
@@ -450,11 +448,15 @@
static _INLINE_ void transmit_chars(struct mcf_serial *info,
volatile unsigned char *uartp)
{
+/*
#if defined(CONFIG_LEDMAN)
ledman_cmd(LEDMAN_CMD_SET, info->line ? LEDMAN_COM2_TX : LEDMAN_COM1_TX);
#endif
+*/
if (info->x_char) {
+// ABK: assert RTS, transmitter should turn it off automatically
when !CRTSCTS
+ uartp[MCFUART_UOP1] = MCFUART_UOP_RTS;
/* Send special char - probably flow control */
uartp[MCFUART_UTB] = info->x_char;
info->x_char = 0;
@@ -464,10 +466,15 @@
if ((info->xmit_cnt <= 0) || info->tty->stopped) {
info->imr &= ~MCFUART_UIR_TXREADY;
uartp[MCFUART_UIMR] = info->imr;
+// ABK: turn off transmitter
+ uartp[MCFUART_UCR] = MCFUART_UCR_TXDISABLE;
return;
}
-
+
while (uartp[MCFUART_USR] & MCFUART_USR_TXREADY) {
+// ABK: assert RTS, transmitter should turn it off automatically
when !CRTSCTS
+ uartp[MCFUART_UOP1] = MCFUART_UOP_RTS;
+
uartp[MCFUART_UTB] = info->xmit_buf[info->xmit_tail++];
info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE-1);
info->stats.tx++;
@@ -824,6 +831,9 @@
if (cflag & CRTSCTS) {
mr1 |= MCFUART_MR1_RXRTS;
mr2 |= MCFUART_MR2_TXCTS;
+ } else {
+// ABK added automatic RTS mode if CRTSCTS is not enabled.
+ mr2 |= MCFUART_MR2_TXRTS;
}
if (cflag & CLOCAL)
@@ -855,6 +865,7 @@
#endif
uartp[MCFUART_UCSR] = MCFUART_UCSR_RXCLKTIMER | MCFUART_UCSR_TXCLKTIMER;
uartp[MCFUART_UCR] = MCFUART_UCR_RXENABLE | MCFUART_UCR_TXENABLE;
+
mcfrs_setsignals(info, 1, -1);
restore_flags(flags);
return;
@@ -951,6 +962,9 @@
restore_flags(flags);
}
+// ABK enable the transmitter
+ uartp[MCFUART_UCR] = MCFUART_UCR_TXENABLE;
+
return total;
}
@@ -1815,7 +1829,8 @@
icrp = (volatile unsigned char *) (MCF_MBAR + MCFICM_INTC0 +
MCFINTC_ICR0 + MCFINT_UART0 + info->line);
/* UART interrupt level and priority */
- *icrp = 0x30 + (info->line ? 3 : 2);
+ *icrp = 0x30 + (info->line ? 7 : 6);
+// *icrp = 0x30 + (info->line ? 3 : 2);
imrp = (volatile unsigned long *) (MCF_MBAR + MCFICM_INTC0 +
MCFINTC_IMRL);
@@ -1841,8 +1856,14 @@
#if defined(CONFIG_M5280) || defined(CONFIG_M5282)
/* Enable the output lines for the serial port */
if (info->line < 2) {
+ unsigned char x;
+
portp = (volatile unsigned char *) (MCF_MBAR + MCF5282_GPIO_PUAPAR);
*portp |= (0x03 << (info->line*2));
+
+// ABK: set up PTC0 as UCTS1, PTC1 as UCTS0, PTC2 as URTS1, and PTC3 as
URTS0.
+ portp = (volatile unsigned char *) (MCF_MBAR + MCF5282_GPIO_PTCPAR);
+ *portp = 0x66;
} else {
printk("SERIAL: don't know how to enable outputs "
"for UART %d?\n", info->line);

On Tuesday 13 December 2005 9:30 am, Aaron Shepard wrote:
> If you don't mind me asking, what was your exact procedure? For
> example: Set nRTS, drop a char into the tx buffer, monitor TxEMPTY,
> disable transmitter, etc.
>
> For us, turning off the transmitter (with the TxRTS bit set) did not
> negate the nRTS line.
>
> Thanks,
> Aaron Shepard
> Harrison Audio

>
> >The 5282.
> >I just noticed something in the manual about disabling the transmitter.
> >I'm going to try that and see if anything different happens.
> >I'll let you know
> >
> >NZG
>
> --------------------------------------------------------------------
Dec 13, 2005, 9:38 AM
Post #7 of 7 (51 views)
Copy Shortcut
 Re: [ColdFire] Coldfire Auto RTS toggle [In reply to]  Can't Post 
--------------------------------------------------------------------------------
 
FWIW:
I've just been experimenting with this very feature on a MCF5213. This chip requires the following:
- When setting up the serial port, enable the TxRTS bit in UMR2 and set the bit(s) in the pin assignment register for the GPIO port that makes the pin work as a RTS output.
- When sending a group of characters, enable the transmitter by writing 0x04 to the UCR register, and manually assert RTS by writing 0x01 to the UOP1 register (RTS is active low, so this actually takes the output low) before writing anything to the transmit register.
- After writing the last character to the transmit register, disable the transmitter by writing 0x08 to the UCR register.
All of the described actions are necessary. Omitting any one of them results in the RTS output not functioning as intended.
One should be aware that the serial ports in different ColdFire derivatives aren't all identical. Sometimes there are significant differences. Read the manual carefully and don't automatically assume things will work as you're used to from another ColdFire variant.
Regards,
Harald Hallen
*********** REPLY SEPARATOR ***********
On 2005-12-13 at 09:30 Aaron Shepard wrote:
>If you don't mind me asking, what was your exact procedure? For
>example: Set nRTS, drop a char into the tx buffer, monitor TxEMPTY,
>disable transmitter, etc.
>
>For us, turning off the transmitter (with the TxRTS bit set) did not
>negate the nRTS line.
>
>Thanks,
>Aaron Shepard
>Harrison Audio
>www.harrisonconsoles.com
>
>>The 5282.
>>I just noticed something in the manual about disabling the transmitter.
>>I'm going to try that and see if anything different happens.
>>I'll let you know
>>
>>NZG
>>
>>
>
>--------------------------------------------------------------------

Message Edited by Dietrich on 04-03-2006 10:48 AM

Message Edited by Dietrich on 04-04-2006 09:08 PM

Outcomes