<?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 Re: printf - MC68HC908BQ8 in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/printf-MC68HC908BQ8/m-p/165997#M4865</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;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;To send the value of a global variable, via the SCI module, will require the following steps -&lt;/FONT&gt;&lt;/DIV&gt;&lt;OL&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Convert the variable value to an ASCII string sequence (null terminated), placed within an array variable.&amp;nbsp; The following thread may&amp;nbsp;provide some ideas on&amp;nbsp;how to do this -&lt;BR /&gt;&lt;A href="http://forums.freescale.com/freescale/board/message?board.id=CWCOMM&amp;amp;thread.id=5423" target="_blank"&gt;http://forums.freescale.com/freescale/board/message?board.id=CWCOMM&amp;amp;thread.id=5423&lt;/A&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Send the contents of the array variable, character by character, to the SCI module.&amp;nbsp; The TERMIO_PutChar() function within the file termio.c may be used for this purpose.&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;byte ascbuf[20];&amp;nbsp; // Global array variable for string data&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;void send_str(void)&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;{&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp; byte i = 0;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp; while (ascbuf[i] &amp;gt; 0)&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TERMIO_SendChar(ascbuf[i++]);&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;}&lt;/FONT&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;The reason your previous attempt to use TERMIO_SendChar() failed is that you probably did not call TERMIO_Init() (also&amp;nbsp;within termio.c file), prior to calling TERMIO_SendChar() for the first time.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Your own sample code for TERMIO_SendChar() is problematic because it seems to assume that SCI communications will be interrupt driven, and therefore fills a circular buffer with the character data.&amp;nbsp; However, this would also require&amp;nbsp;ISR code for the SCI, to be able to send the data, and empty the buffer.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;The code within termio.c does not use interrupts, so will tie up further code execution while the string data is sent.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by bigmac on &lt;SPAN class="date_text"&gt;2007-11-23&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;01:49 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 23 Nov 2007 11:40:35 GMT</pubDate>
    <dc:creator>bigmac</dc:creator>
    <dc:date>2007-11-23T11:40:35Z</dc:date>
    <item>
      <title>printf - MC68HC908BQ8</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/printf-MC68HC908BQ8/m-p/165992#M4860</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;Hi everyone,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I am using codewarrior IDE Version 5.9.0. And controller is MC68HC908BQ8.&lt;/DIV&gt;&lt;DIV&gt;I want to print the data of a global variable, I have included stdio.h and compiled&lt;/DIV&gt;&lt;DIV&gt;the compiler error I got was&lt;P&gt;&lt;SPAN style=": ; color: #000000; font-size: 3; font-family: 'Times New Roman';"&gt;"Symbol TERMIO_PutChar in file C:\Program Files\Freescale\CodeWarrior for Microcontrollers V6.0\lib\hc08c\lib\ansii.lib&amp;nbsp;is undefined"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; color: #000000; font-size: 3; font-family: 'Times New Roman';"&gt;So I have included termio.c file and terminal.c&amp;nbsp;&amp;nbsp;the program get comiled but I got run time error at location&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; color: #000000; font-size: 3; font-family: 'Times New Roman';"&gt;Error: At location 0203 -&lt;BR /&gt;Error: Attempt to use invalid or uninitialized memory&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; color: #000000; font-size: 3; font-family: 'Times New Roman';"&gt;I got this error when I tried to execute&amp;nbsp;the line in Bold&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; color: #000000; font-size: 3; font-family: 'Times New Roman';"&gt;"if TEST_TERM&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;while (!(SCI.SCSR &amp;amp; 0x80)) {};&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* wait for output buffer empty */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SCI.SCDR = ch;"&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style=": ; color: #000000; font-size: 3; font-family: 'Times New Roman';"&gt;This&amp;nbsp;code is&amp;nbsp;termio.c file&lt;/SPAN&gt;&lt;P&gt;&lt;SPAN style=": ; color: #000000; font-size: 3; font-family: 'Times New Roman';"&gt;&lt;BR /&gt;&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;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;And I got this code from the forum and tried to compile&lt;/DIV&gt;&lt;DIV&gt;#include &amp;lt;hidef.h&amp;gt;&lt;BR /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;BR /&gt;#include &amp;lt;termio.h&amp;gt;&lt;BR /&gt;char buf[20];&lt;BR /&gt;int bufpos;&lt;BR /&gt;void TERMIO_Init(void) {&lt;BR /&gt;}&lt;BR /&gt;void TERMIO_PutChar(char ch) {&lt;BR /&gt;buf[bufpos]= ch;&lt;BR /&gt;bufpos++;&lt;BR /&gt;if (bufpos &amp;gt;= sizeof(buf)) {&lt;BR /&gt;bufpos -= sizeof(buf);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;int dtTarget= 2;&lt;BR /&gt;void main(void) {&lt;BR /&gt;(void)printf("SP %u\n\r", dtTarget );&lt;/DIV&gt;&lt;DIV&gt;while (1) { _FEED_COP(); }&lt;BR /&gt;}&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I got error as "&lt;SPAN style=": ; color: #000000;"&gt;Link Error&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt; : L1102: Out of allocation space in segment RAM at address 0x11E".&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style=": ; color: #000000;"&gt;Can someone provide the piece of code to print.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Nov 2007 20:58:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/printf-MC68HC908BQ8/m-p/165992#M4860</guid>
      <dc:creator>Opal</dc:creator>
      <dc:date>2007-11-21T20:58:54Z</dc:date>
    </item>
    <item>
      <title>Re: printf - MC68HC908BQ8</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/printf-MC68HC908BQ8/m-p/165993#M4861</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hello and welcome Opal,&lt;BR /&gt;&lt;BR /&gt;In the first instance, as SCSR is being read, modify, written. CW does not like to read from locations that have not previously been written too. Just initialise this variable (even if you are just writing the POR value, before you get to this point in the programme.&lt;BR /&gt;In the second it appears you have run out of RAM, or at least the amount you have allocated here.&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Nov 2007 05:04:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/printf-MC68HC908BQ8/m-p/165993#M4861</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2007-11-22T05:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: printf - MC68HC908BQ8</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/printf-MC68HC908BQ8/m-p/165994#M4862</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&amp;nbsp;First, printf is rather resource demanding, so I'm wondering if you might not be better using some more light weight way of printing to the SCI.&lt;BR /&gt;And second, the "TEST_TERM" part of termio.c wont work for a HC08 in the&lt;BR /&gt;debugger, neither on real hardware nor in the simulator :smileysad:.&lt;BR /&gt;Sorry, I dont know the details about the BQ8 device to help more, if it has a SCI module, it should not be hard to implement the two functions needed (TERMIO_PutChar, and the SCI has to be initialized too, an empty TERMIO_Init wont do that....).&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by CompilerGuru on &lt;SPAN class="date_text"&gt;2007-11-21&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;10:46 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Nov 2007 05:45:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/printf-MC68HC908BQ8/m-p/165994#M4862</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2007-11-22T05:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: printf - MC68HC908BQ8</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/printf-MC68HC908BQ8/m-p/165995#M4863</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;I wonder if the OP actually means 908QB8, rather than 908BQ8?&amp;nbsp; If so, there&amp;nbsp;are only 256 bytes of RAM available, and potential resource limit problems are compounded by the default PRM file, which confines both the globals and stack to&amp;nbsp;page-1 RAM (64 bytes).&amp;nbsp; The PRM file will probably need to be altered, whether or not printf is utilized.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;I agree that this particular device does not have sufficient resources to handle printf or sprintf.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Nov 2007 12:41:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/printf-MC68HC908BQ8/m-p/165995#M4863</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-11-22T12:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: printf - MC68HC908BQ8</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/printf-MC68HC908BQ8/m-p/165996#M4864</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Thanks to everyone&lt;/DIV&gt;&lt;DIV&gt;Is that possible to write my own printf if so can someone guide me&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Nov 2007 14:18:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/printf-MC68HC908BQ8/m-p/165996#M4864</guid>
      <dc:creator>Opal</dc:creator>
      <dc:date>2007-11-22T14:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: printf - MC68HC908BQ8</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/printf-MC68HC908BQ8/m-p/165997#M4865</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;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;To send the value of a global variable, via the SCI module, will require the following steps -&lt;/FONT&gt;&lt;/DIV&gt;&lt;OL&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Convert the variable value to an ASCII string sequence (null terminated), placed within an array variable.&amp;nbsp; The following thread may&amp;nbsp;provide some ideas on&amp;nbsp;how to do this -&lt;BR /&gt;&lt;A href="http://forums.freescale.com/freescale/board/message?board.id=CWCOMM&amp;amp;thread.id=5423" target="_blank"&gt;http://forums.freescale.com/freescale/board/message?board.id=CWCOMM&amp;amp;thread.id=5423&lt;/A&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Send the contents of the array variable, character by character, to the SCI module.&amp;nbsp; The TERMIO_PutChar() function within the file termio.c may be used for this purpose.&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;byte ascbuf[20];&amp;nbsp; // Global array variable for string data&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;void send_str(void)&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;{&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp; byte i = 0;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp; while (ascbuf[i] &amp;gt; 0)&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TERMIO_SendChar(ascbuf[i++]);&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;}&lt;/FONT&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;The reason your previous attempt to use TERMIO_SendChar() failed is that you probably did not call TERMIO_Init() (also&amp;nbsp;within termio.c file), prior to calling TERMIO_SendChar() for the first time.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Your own sample code for TERMIO_SendChar() is problematic because it seems to assume that SCI communications will be interrupt driven, and therefore fills a circular buffer with the character data.&amp;nbsp; However, this would also require&amp;nbsp;ISR code for the SCI, to be able to send the data, and empty the buffer.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;The code within termio.c does not use interrupts, so will tie up further code execution while the string data is sent.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by bigmac on &lt;SPAN class="date_text"&gt;2007-11-23&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;01:49 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Nov 2007 11:40:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/printf-MC68HC908BQ8/m-p/165997#M4865</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-11-23T11:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: printf - MC68HC908BQ8</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/printf-MC68HC908BQ8/m-p/165998#M4866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I want to send/communicate through SPI.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;1.Can I Use printf to send data through SPI?&lt;/DIV&gt;&lt;DIV&gt;2.I have used the following code to transmit data through SPI.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;I have used stimulation to check whether the data is coming correct.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; When I send integer value The output is coming correctly in &lt;EM&gt;SPI Module&lt;/EM&gt; ---&amp;gt;View SPI data. But when tried to send this as&amp;nbsp;char (ie)&amp;nbsp; I have converted hex to dec and to ASCII value then from third data an 0x80 is getting added only in the display but the data is send through register is correct I have checked this through the statement &lt;EM&gt;&lt;U&gt;&lt;FONT color="#FF99FF"&gt;na[i]=*(data+i);&lt;/FONT&gt;&lt;/U&gt;&lt;/EM&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;I dont able to understand , why is it happening so?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;Whether what am I doing in the program is correct?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&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; /* for EnableInterrupts macro */#include "derivative.h" /* include peripheral declarations */#include &amp;lt;string.h&amp;gt;void sendSPI(char *,int);void delay1s(void);void main(void) {int y,rec_data,len;                   //y,rec_data,,lenchar name[8]="Vowelopal"; OSCSC = 0x20;       // Set bus speed to 12.8 MHZ  OSCTRIM = Optional; // this macro loads value at $FFC0 and store it in $0038.                // bus clock speed is 3.2MHz +- 5%  CONFIG1 = 0x01;     // disable the watch dog.    SPSCR = 0x03;                                    SPCR_SPE = 1;  SPCR_SPMSTR = 1;  SPCR_CPHA = 1;  len=strlen(name) ; while(1) {   sendSPI(name,len);  SPDR = 0xAA;    while(!SPSCR_SPRF);    delay1s();  y = SPSCR;  rec_data = SPDR;     }  }  &lt;FONT color="#6633FF"&gt;void sendSPI(char *data,int le)&lt;/FONT&gt; {   char i = 0;  int rec_data;   for(i=0; i&amp;lt;(le-1); i++)     {      SPDR = *(data+i);      //na[i]=*(data+i);            while(!SPSCR_SPRF);          SPSCR = SPSCR;      rec_data = SPDR;      delay1s(); }   }void delay1s(void) {   unsigned int i;  int j;   for(j=0;j&amp;lt;10;j++)    {     for (i = 0; i &amp;lt;= 20899;i++);          // Delay of 100mS   }                                       // 15 cycles per delay value                                // 6 uS for a 2.5 MHz clock                                          // 6 uS * 167000 = 1000 mS = 1 sec }&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:13:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/printf-MC68HC908BQ8/m-p/165998#M4866</guid>
      <dc:creator>Opal</dc:creator>
      <dc:date>2020-10-29T09:13:00Z</dc:date>
    </item>
  </channel>
</rss>

