<?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 Troublewith SCI transmit on S12C32 in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Troublewith-SCI-transmit-on-S12C32/m-p/187944#M7156</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to write a simple program to output data on the sci port of a MC9S12C32. My problem is that when I write a value to the SCIDRL register, the value is not written and 0x00 is written instead. However when I write to SCIDRH it works fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Below is the code i am trying to run.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;#include &amp;lt;hidef.h&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* common defines and macros */
#include &amp;lt;mc9s12c32.h&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12c32"

#define BAUD_RATE_DIVIDER 130 // 9600&amp;nbsp; Baud


void sendData(void);
void initialize(void);
void interrupt 20 sciHandler(void);

int sendCount;
int done;

void main(void) {

&amp;nbsp; initialize();
&amp;nbsp; EnableInterrupts;
 
&amp;nbsp; sendData();

&amp;nbsp; for(;;)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if(done) { break; }}void initialize(void) { // initalize the system&amp;nbsp; done = 0;&amp;nbsp; sendCount = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp; // clear flags&amp;nbsp; SCISR1;&amp;nbsp; SCIDRL = 1;&amp;nbsp;&amp;nbsp;&amp;nbsp; // initialize SCI module&amp;nbsp;&amp;nbsp;&amp;nbsp; SCIBDH = 0x00;&amp;nbsp; SCIBDL = BAUD_RATE_DIVIDER;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SCICR1 = 0x00;&amp;nbsp; SCICR2 = 0xC8;// turn on tx and related interrupts}void sendData(void) {&amp;nbsp; SCIDRH = 0xFF; // this works and writes 0x40 to the register (T8)&amp;nbsp; SCIDRL = 0x55; // this writes 0x00 to the register&amp;nbsp;&amp;nbsp;&amp;nbsp; // I've also tried this and got the same results&amp;nbsp; //asm {&amp;nbsp; //&amp;nbsp; movb&amp;nbsp; $FF,SCIDRL;&amp;nbsp; //}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(sendCount++ == 100) { done = 1; }}void interrupt 20 sciHandler(void) {&amp;nbsp; if(SCISR1_TC){// Transmit Complete&amp;nbsp;&amp;nbsp;&amp;nbsp; //sendData();&amp;nbsp; }&amp;nbsp; if(SCISR1_TDRE){// Transmit Data Register Empty&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(done == 0){&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sendData();&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp; }}&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;Any thoughts on what I am doing wrong?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Oct 2020 09:39:05 GMT</pubDate>
    <dc:creator>pdarg</dc:creator>
    <dc:date>2020-10-29T09:39:05Z</dc:date>
    <item>
      <title>Troublewith SCI transmit on S12C32</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Troublewith-SCI-transmit-on-S12C32/m-p/187944#M7156</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to write a simple program to output data on the sci port of a MC9S12C32. My problem is that when I write a value to the SCIDRL register, the value is not written and 0x00 is written instead. However when I write to SCIDRH it works fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Below is the code i am trying to run.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;#include &amp;lt;hidef.h&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* common defines and macros */
#include &amp;lt;mc9s12c32.h&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12c32"

#define BAUD_RATE_DIVIDER 130 // 9600&amp;nbsp; Baud


void sendData(void);
void initialize(void);
void interrupt 20 sciHandler(void);

int sendCount;
int done;

void main(void) {

&amp;nbsp; initialize();
&amp;nbsp; EnableInterrupts;
 
&amp;nbsp; sendData();

&amp;nbsp; for(;;)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if(done) { break; }}void initialize(void) { // initalize the system&amp;nbsp; done = 0;&amp;nbsp; sendCount = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp; // clear flags&amp;nbsp; SCISR1;&amp;nbsp; SCIDRL = 1;&amp;nbsp;&amp;nbsp;&amp;nbsp; // initialize SCI module&amp;nbsp;&amp;nbsp;&amp;nbsp; SCIBDH = 0x00;&amp;nbsp; SCIBDL = BAUD_RATE_DIVIDER;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SCICR1 = 0x00;&amp;nbsp; SCICR2 = 0xC8;// turn on tx and related interrupts}void sendData(void) {&amp;nbsp; SCIDRH = 0xFF; // this works and writes 0x40 to the register (T8)&amp;nbsp; SCIDRL = 0x55; // this writes 0x00 to the register&amp;nbsp;&amp;nbsp;&amp;nbsp; // I've also tried this and got the same results&amp;nbsp; //asm {&amp;nbsp; //&amp;nbsp; movb&amp;nbsp; $FF,SCIDRL;&amp;nbsp; //}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(sendCount++ == 100) { done = 1; }}void interrupt 20 sciHandler(void) {&amp;nbsp; if(SCISR1_TC){// Transmit Complete&amp;nbsp;&amp;nbsp;&amp;nbsp; //sendData();&amp;nbsp; }&amp;nbsp; if(SCISR1_TDRE){// Transmit Data Register Empty&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(done == 0){&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sendData();&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp; }}&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;Any thoughts on what I am doing wrong?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:39:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Troublewith-SCI-transmit-on-S12C32/m-p/187944#M7156</guid>
      <dc:creator>pdarg</dc:creator>
      <dc:date>2020-10-29T09:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: Troublewith SCI transmit on S12C32</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Troublewith-SCI-transmit-on-S12C32/m-p/187945#M7157</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;For starters, you can't write data to SCIDRL and then read that data back.&amp;nbsp; When you read SCIDRL it is reading received data.&amp;nbsp; If you want a write to SCIDRL and then read it from SCIDRL you will need to set the LOOPS bit in SCICR1. There should be no reason to read/write to SCIDRH unless you are doing 9-bit data&amp;nbsp;transfers which you are not (you enable this by setting the M bit in SCIDRL, but I don't think you are wanting a 9-bit data&amp;nbsp;transfer).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;edit: For information on the SCI module for the S12 take a look at:&lt;/DIV&gt;&lt;DIV&gt;&lt;A href="http://www.freescale.com/files/microcontrollers/doc/ref_manual/S12SCIV2.pdf?fsrch=1" rel="nofollow" target="_blank"&gt;http://www.freescale.com/files/microcontrollers/doc/ref_manual/S12SCIV2.pdf?fsrch=1&lt;/A&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by allawtterb on &lt;SPAN class="date_text"&gt;2008-02-08&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;10:56 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Feb 2008 06:49:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Troublewith-SCI-transmit-on-S12C32/m-p/187945#M7157</guid>
      <dc:creator>allawtterb</dc:creator>
      <dc:date>2008-02-09T06:49:04Z</dc:date>
    </item>
    <item>
      <title>Re: Troublewith SCI transmit on S12C32</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Troublewith-SCI-transmit-on-S12C32/m-p/187946#M7158</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;When you write to the register it is Tx data, when you read from this register it is Rx data, so unless you you just happen to have received the exact same data you&amp;nbsp; sent, I would expect the Rx data to be 0 most of the time.&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Feb 2008 06:58:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Troublewith-SCI-transmit-on-S12C32/m-p/187946#M7158</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2008-02-09T06:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: Troublewith SCI transmit on S12C32</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Troublewith-SCI-transmit-on-S12C32/m-p/187947#M7159</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Thanks for the quick replies, I appreciate it.&lt;BR /&gt;&lt;BR /&gt;I am a little confused. I am viewing the registers' content using the True Time simulator with Codewarrior. When you mention reading the value of of SCIDRL I am assuming you mean that the simulator's memory watch feature reads the register and the read only returns the value contained in the Rx register, not Tx.&lt;BR /&gt;&lt;BR /&gt;I am still not able to view the contents even when LOOP and RE are set. Perhaps I am missing some concept here.&lt;BR /&gt;&lt;BR /&gt;I was writing to the SCIDRH register as a proof of concept that I was actually performing the operation correctly, not for any functional reason.&lt;BR /&gt;&lt;BR /&gt;Another thing that has me puzzled is that only one byte is sent. Since the interrupts are enabled I would expect that the TDRE interrupt would be called once for each byte I write into SCIDRL.&lt;BR /&gt;&lt;BR /&gt;I am a beginner with the HCS12 and feel like I just dont fully understand some of the concepts involved here.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Feb 2008 09:43:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Troublewith-SCI-transmit-on-S12C32/m-p/187947#M7159</guid>
      <dc:creator>pdarg</dc:creator>
      <dc:date>2008-02-09T09:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: Troublewith SCI transmit on S12C32</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Troublewith-SCI-transmit-on-S12C32/m-p/187948#M7160</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;Well, the concept you may be missing is that the Tx data register simply CAN'T be read at all, not in the simulator or on the real thing, because it shares an i/o port address with the Rx registers. Although there really are two registers on the chip, a write to that port address writes to the Tx register, while a a read reads the Rx register, a completely different register. This applies to the Low part of the register, bu the high part is slightly different with regards to bit T8. If you look in the spec, that is the same bit for both read and write. Odd, but thats the way it is. You can stop worrying about that. What you see is what would be expected.&lt;BR /&gt;&lt;BR /&gt;If you are using CodeWarrior, try generating sample code in Processor Expert. As far as I know this should work in the simulator at least the Tx interrupts should happen.&lt;BR /&gt;There are some samples &lt;A href="http://www.mecheng.adelaide.edu.au/robotics/wpage.php?wpage_id=56#_Dragon12_sample_programs" rel="nofollow" target="_blank"&gt;here&lt;/A&gt; that might help as well. These were wirtten for the DP, and may apply to the C version as well.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="time_text"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by JimDon on &lt;SPAN class="date_text"&gt;2008-02-09&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;01:00 AM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Feb 2008 13:52:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Troublewith-SCI-transmit-on-S12C32/m-p/187948#M7160</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2008-02-09T13:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: Troublewith SCI transmit on S12C32</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Troublewith-SCI-transmit-on-S12C32/m-p/187949#M7161</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Thanks, I was able to figure it out.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Feb 2008 05:23:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Troublewith-SCI-transmit-on-S12C32/m-p/187949#M7161</guid>
      <dc:creator>pdarg</dc:creator>
      <dc:date>2008-02-11T05:23:32Z</dc:date>
    </item>
  </channel>
</rss>

