<?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: IAR UART_Setcallback function problem in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/IAR-UART-Setcallback-function-problem/m-p/329503#M15318</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Paul,&lt;/P&gt;&lt;P&gt;I realize that I forgot some of my code!&lt;/P&gt;&lt;P&gt;In my main() function, I have this line:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;UART_SetCallback(UART_Rx_Task);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This should reference the function I wrote previously. At least, that is how I use it for the FTMx interrupts, with no problems.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Jan 2015 21:40:46 GMT</pubDate>
    <dc:creator>davetelling</dc:creator>
    <dc:date>2015-01-08T21:40:46Z</dc:date>
    <item>
      <title>IAR UART_Setcallback function problem</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/IAR-UART-Setcallback-function-problem/m-p/329501#M15316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a UART function that should receive an ASCII character, put it into a small buffer, increment a buffer counter, and set a flag if a CR or LF is received. This function should occur when the KE02Z UART1 generates an RDRF as a complete character comes into the UART.&lt;/P&gt;&lt;P&gt;Here is the interrupt function:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;void UART_Rx_Task(void)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; uint8_t tempData;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; /* reset RDB flag */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; tempData = UART_CheckFlag(UART1, UART_FlagRDRF);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; /* read the character and put into buffer */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; inChar[rxBufCount] = UART_ReadDataReg(UART1);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; if ((inChar[rxBufCount] == CR) || (inChar[rxBufCount] == LF))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; {&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rxFull = true;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rxBufCount = 0;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; }&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; else&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; {&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rxBufCount++;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (rxBufCount &amp;gt;= rxMax)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rxBufCount = 0;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rxFull = true;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; }&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; Without going into a discussion about the best way to do this, my real problem is that I cannot seem to tell the program to uses this interrupt.&lt;/P&gt;&lt;P&gt;The IAR tools have a predefined function (in 'uart.h'):&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;void UART_SetCallback(UART_CallbackType pfnCallback);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; The "CallbackType" is defined like this:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;typedef void (*UART_CallbackType)(UART_Type *pUART);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I am not exactly sure what this means - C syntax is not my field of expertise, and when I try to compile this, I get this error message:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Error[Pe167]: argument of type "void (*)(void)" is incompatible with parameter of type "UART_CallbackType" &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Can someone explain what exactly this means, in non-professional programmer language?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 20:07:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/IAR-UART-Setcallback-function-problem/m-p/329501#M15316</guid>
      <dc:creator>davetelling</dc:creator>
      <dc:date>2015-01-08T20:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: IAR UART_Setcallback function problem</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/IAR-UART-Setcallback-function-problem/m-p/329502#M15317</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The &lt;STRONG&gt;"void (*)(void)"&lt;/STRONG&gt; error means you've created a function that take no inputs, but to be compatible, it needs to take 1 input of type "UART_CallbackType".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You're not required to actually &lt;STRONG&gt;*do*&lt;/STRONG&gt; anything with whatever data you get from the input parameter.&amp;nbsp; But you must accept the input parameter to get your function called, because the code which already exists to call your function passes &lt;EM&gt;something&lt;/EM&gt; in that parameter.&amp;nbsp; Your function just can't be compatible if it doesn't receive the data which the calling code sends.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ps: if anyone from Freescale sees this reply.... I had to try several times to log in.&amp;nbsp; I got an unhelpful "unsuccessful" error several times, and even one "500 - Internal Server Error" from your site.&amp;nbsp; I nearly gave up.&amp;nbsp; Why bother with a troublesome website, just to answer a random tech question?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 21:13:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/IAR-UART-Setcallback-function-problem/m-p/329502#M15317</guid>
      <dc:creator>paulstoffregen</dc:creator>
      <dc:date>2015-01-08T21:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: IAR UART_Setcallback function problem</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/IAR-UART-Setcallback-function-problem/m-p/329503#M15318</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Paul,&lt;/P&gt;&lt;P&gt;I realize that I forgot some of my code!&lt;/P&gt;&lt;P&gt;In my main() function, I have this line:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;UART_SetCallback(UART_Rx_Task);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This should reference the function I wrote previously. At least, that is how I use it for the FTMx interrupts, with no problems.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 21:40:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/IAR-UART-Setcallback-function-problem/m-p/329503#M15318</guid>
      <dc:creator>davetelling</dc:creator>
      <dc:date>2015-01-08T21:40:46Z</dc:date>
    </item>
    <item>
      <title>Re: IAR UART_Setcallback function problem</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/IAR-UART-Setcallback-function-problem/m-p/329504#M15319</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The problem is how you created your function:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;void UART_Rx_Task(void)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's not acceptable to use "(void)" to define your function.&amp;nbsp; It doesn't matter if that works for other cases like FTM.&amp;nbsp; The code you're trying to use requires your function to be like this:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;void UART_Rx_Task(&lt;/STRONG&gt;&lt;STRONG&gt;UART_Type *pUART)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Even if you don't want the pUART variable, your function MUST be defined this way, because that other code sends a pUART variable when it calls your function.&amp;nbsp; It's illegal to try to use a function that doesn't take anything as input, because the code which already exists sends something in pUART.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;That's what the compiler is trying to tell you, and I'm trying to tell you too.&amp;nbsp; Maybe you don't want to believe us?&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 21:50:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/IAR-UART-Setcallback-function-problem/m-p/329504#M15319</guid>
      <dc:creator>paulstoffregen</dc:creator>
      <dc:date>2015-01-08T21:50:41Z</dc:date>
    </item>
    <item>
      <title>Re: IAR UART_Setcallback function problem</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/IAR-UART-Setcallback-function-problem/m-p/329505#M15320</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Welll...I am not sure what to believe at this point. I have written assembler and 'C' for several microcontrollers over the years, currently the Atmel AVR series, and I have never had the problems I have encountered trying to make this ARM Cortex part work. Since I am not a programmer, but an engineer, I don't code all the time, only when I need firmware for a project, so please bear with me.&lt;/P&gt;&lt;P&gt;Adding "UART_Type *pUART" in the parentheses allowed the program to compile, and my isr is reached when I send a character, so I thank you very much for your help. I still do not understand why IAR has set up their examples like this, but at this point, I need to move on.&lt;/P&gt;&lt;P&gt;Thank you again for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jan 2015 22:47:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/IAR-UART-Setcallback-function-problem/m-p/329505#M15320</guid>
      <dc:creator>davetelling</dc:creator>
      <dc:date>2015-01-08T22:47:29Z</dc:date>
    </item>
  </channel>
</rss>

