<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic MCF5206 polled UART TX issues in ColdFire/68K Microcontrollers and Processors</title>
    <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF5206-polled-UART-TX-issues/m-p/1654196#M14390</link>
    <description>&lt;P&gt;I'm writing some custom firmware for a 25 year old system based on the MCF5206.&lt;BR /&gt;&lt;BR /&gt;I find myself completely unable to transmit any data from UART1, using polling of the USR register, rather than interrupts.&lt;BR /&gt;&lt;BR /&gt;My UART initialisation code looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;	volatile SIM_UART* u = &amp;amp;_sim_base-&amp;gt;UART1;

	u-&amp;gt;UCR = UART_UCR_RESET_RECEIVER;
	u-&amp;gt;UCR = UART_UCR_RESET_TRANSMITTER;
	u-&amp;gt;UCR = UART_UCR_RESET_MODE;
	u-&amp;gt;UCR = UART_UCR_RESET_ERROR;
	u-&amp;gt;UCR = UART_UCR_RESET_BREAK;

	u-&amp;gt;UIPCR_UACR = 0;						// IEC = 0
	u-&amp;gt;UISR_UIMR = 0;						// no interrupts
	u-&amp;gt;USR_UCSR = 0xdd;						// use timer for rx/tx clock

	// set clock for 31250 baud
	const uint16_t ubg = 33000000 / (32 * 31250);
	u-&amp;gt;UBG1 = (ubg &amp;gt;&amp;gt; &lt;LI-EMOJI id="lia_smiling-face-with-sunglasses" title=":smiling_face_with_sunglasses:"&gt;&lt;/LI-EMOJI&gt; &amp;amp; 0xff;
	u-&amp;gt;UBG2 = (ubg &amp;gt;&amp;gt; 0) &amp;amp; 0xff;

	u-&amp;gt;UMR = 0x13;							// UMR1: 8 bits, no parity
	u-&amp;gt;UMR = 0x07;							// UMR2: 1 stop bit

	u-&amp;gt;UCR = UART_UCR_TX_ENABLE;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and my transmit code like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;	volatile SIM_UART* u = &amp;amp;_sim_base-&amp;gt;UART1;
	uint32_t count = 0;
	uint8_t led = 0x40;

	*io_u35 = 0x20;

	while ((u-&amp;gt;USR_UCSR &amp;amp; UART_USR_TX_READY) == 0) {
		*io_u35 = led;
		if (++count == 50000) {
			count = 0;
			led = 0x40 - led;
		}
	}

	u-&amp;gt;URB_UTB = n;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The code inside the UART write loop is just there to flash a front panel LED every 50k times around the loop.&amp;nbsp; The loop never exits, so it seems TxRdy is never getting asserted.&lt;BR /&gt;&lt;BR /&gt;I found a post relating to the 5213 saying that the UARTs don't work right after a power-on-reset, but the proposed fix (writing to the Reset Control Register) doesn't exist on the 5206.&lt;BR /&gt;&lt;BR /&gt;Am I missing something fundamental about how to use the transmit interface?&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 21 May 2023 11:22:27 GMT</pubDate>
    <dc:creator>raybellis</dc:creator>
    <dc:date>2023-05-21T11:22:27Z</dc:date>
    <item>
      <title>MCF5206 polled UART TX issues</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF5206-polled-UART-TX-issues/m-p/1654196#M14390</link>
      <description>&lt;P&gt;I'm writing some custom firmware for a 25 year old system based on the MCF5206.&lt;BR /&gt;&lt;BR /&gt;I find myself completely unable to transmit any data from UART1, using polling of the USR register, rather than interrupts.&lt;BR /&gt;&lt;BR /&gt;My UART initialisation code looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;	volatile SIM_UART* u = &amp;amp;_sim_base-&amp;gt;UART1;

	u-&amp;gt;UCR = UART_UCR_RESET_RECEIVER;
	u-&amp;gt;UCR = UART_UCR_RESET_TRANSMITTER;
	u-&amp;gt;UCR = UART_UCR_RESET_MODE;
	u-&amp;gt;UCR = UART_UCR_RESET_ERROR;
	u-&amp;gt;UCR = UART_UCR_RESET_BREAK;

	u-&amp;gt;UIPCR_UACR = 0;						// IEC = 0
	u-&amp;gt;UISR_UIMR = 0;						// no interrupts
	u-&amp;gt;USR_UCSR = 0xdd;						// use timer for rx/tx clock

	// set clock for 31250 baud
	const uint16_t ubg = 33000000 / (32 * 31250);
	u-&amp;gt;UBG1 = (ubg &amp;gt;&amp;gt; &lt;LI-EMOJI id="lia_smiling-face-with-sunglasses" title=":smiling_face_with_sunglasses:"&gt;&lt;/LI-EMOJI&gt; &amp;amp; 0xff;
	u-&amp;gt;UBG2 = (ubg &amp;gt;&amp;gt; 0) &amp;amp; 0xff;

	u-&amp;gt;UMR = 0x13;							// UMR1: 8 bits, no parity
	u-&amp;gt;UMR = 0x07;							// UMR2: 1 stop bit

	u-&amp;gt;UCR = UART_UCR_TX_ENABLE;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and my transmit code like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;	volatile SIM_UART* u = &amp;amp;_sim_base-&amp;gt;UART1;
	uint32_t count = 0;
	uint8_t led = 0x40;

	*io_u35 = 0x20;

	while ((u-&amp;gt;USR_UCSR &amp;amp; UART_USR_TX_READY) == 0) {
		*io_u35 = led;
		if (++count == 50000) {
			count = 0;
			led = 0x40 - led;
		}
	}

	u-&amp;gt;URB_UTB = n;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The code inside the UART write loop is just there to flash a front panel LED every 50k times around the loop.&amp;nbsp; The loop never exits, so it seems TxRdy is never getting asserted.&lt;BR /&gt;&lt;BR /&gt;I found a post relating to the 5213 saying that the UARTs don't work right after a power-on-reset, but the proposed fix (writing to the Reset Control Register) doesn't exist on the 5206.&lt;BR /&gt;&lt;BR /&gt;Am I missing something fundamental about how to use the transmit interface?&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 21 May 2023 11:22:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF5206-polled-UART-TX-issues/m-p/1654196#M14390</guid>
      <dc:creator>raybellis</dc:creator>
      <dc:date>2023-05-21T11:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: MCF5206 polled UART TX issues</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF5206-polled-UART-TX-issues/m-p/1654207#M14392</link>
      <description>&lt;P&gt;Do you have any sample code you can copy? I searched and found AN2168. It shows how to use DMA to transmit, but it includes UART initialisation that you might like to compare with yours.&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 21 May 2023 13:57:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF5206-polled-UART-TX-issues/m-p/1654207#M14392</guid>
      <dc:creator>TomE</dc:creator>
      <dc:date>2023-05-21T13:57:40Z</dc:date>
    </item>
    <item>
      <title>Re: MCF5206 polled UART TX issues</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF5206-polled-UART-TX-issues/m-p/1654208#M14393</link>
      <description>&lt;P&gt;I'm working from the 5206 User Manual and the original firmware for the unit.&lt;BR /&gt;&lt;BR /&gt;My code looks *very* similar to that from AN2168, albeit some of the writes done in a different order.&amp;nbsp; I'll try new code based on AN2168 shortly.&lt;/P&gt;</description>
      <pubDate>Sun, 21 May 2023 14:31:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF5206-polled-UART-TX-issues/m-p/1654208#M14393</guid>
      <dc:creator>raybellis</dc:creator>
      <dc:date>2023-05-21T14:31:30Z</dc:date>
    </item>
    <item>
      <title>Re: MCF5206 polled UART TX issues</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF5206-polled-UART-TX-issues/m-p/1654213#M14394</link>
      <description>&lt;P&gt;I've tracked down the problem - it appear to be related to my definition of `_sim_base` with its address specified in my linker script:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;_sim_base = 0x20000000;&lt;/LI-CODE&gt;&lt;P&gt;and imported in C code with:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;extern volatile SIM* _sim_base;&lt;/LI-CODE&gt;&lt;P&gt;It works if I use this instead:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;static volatile SIM* _sim_base = (void*)0x20000000;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;I can't be sure yet, but it appeared that with my original code the system was trying to read the contents of 0x20000000 to find `_sim_base`, rather than treating that as an absolute address in its own right.&lt;/P&gt;</description>
      <pubDate>Sun, 21 May 2023 16:11:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF5206-polled-UART-TX-issues/m-p/1654213#M14394</guid>
      <dc:creator>raybellis</dc:creator>
      <dc:date>2023-05-21T16:11:13Z</dc:date>
    </item>
  </channel>
</rss>

