<?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>Kinetis MicrocontrollersのトピックRe: Get a value outside interrupt uart (and related questions)</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Get-a-value-outside-interrupt-uart-and-related-questions/m-p/268833#M8928</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First of all, &lt;BR /&gt;thank you very much for your reply. &lt;/P&gt;&lt;P&gt;Actually, I already declared my variables as &lt;STRONG&gt;volatile&lt;/STRONG&gt; in processorExpert.c and &lt;STRONG&gt;external volatile&lt;/STRONG&gt; in events.c; anyway they still arent' updated. BTW, using pointers I am able to work around this problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;L.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 03 Mar 2014 07:58:20 GMT</pubDate>
    <dc:creator>Catosh</dc:creator>
    <dc:date>2014-03-03T07:58:20Z</dc:date>
    <item>
      <title>Get a value outside interrupt uart (and related questions)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Get-a-value-outside-interrupt-uart-and-related-questions/m-p/268831#M8926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, &lt;/P&gt;&lt;P&gt;I am currently using UART5 PDD with PE on a k60 with tx interrupts enable. &lt;/P&gt;&lt;P&gt;According to datasheet, I have to read s1 reg and then data reg. Here come the "problems": If I access registers in the interrupt routine (in events.c), I am able to clear the interrupt and then going on with the main cycle: eg. below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13936050800862554" jivemacro_uid="_13936050800862554" modifiedtitle="true"&gt;
&lt;P&gt;void UART5_ISR(void){&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; UART_PDD_ReadStatus1Reg(UART5_BASE_PTR);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tx_data=UART_PDD_ReadDataReg(UART5_BASE_PTR);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uart_rx_flag=1;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BUT then if I try to print tx_data (global, volatile and uint8_t variable) into the main routine with &lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13936051983149487" jivemacro_uid="_13936051983149487" modifiedtitle="true"&gt;
&lt;P&gt;void main(){&lt;/P&gt;
&lt;P&gt;[...]&lt;/P&gt;
&lt;P&gt;while(1)UART_PDD_PutChar8(UART5_BASE_PTR,tx_data);&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;It doesn't update the value. So I have to perform another read operation into the main.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Furthermore, if I try to clear the interrupt OUTSIDE ISR (e.g into the main) e.g&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13936054170696178" jivemacro_uid="_13936054170696178" modifiedtitle="true"&gt;
&lt;P&gt;void main(){&lt;/P&gt;
&lt;P&gt;[...]&lt;/P&gt;
&lt;P&gt;if(1==uart_rx_flag){&lt;/P&gt;
&lt;P&gt; UART_PDD_ReadStatus1Reg(UART5_BASE_PTR);&lt;/P&gt;
&lt;P&gt; tx_data=UART_PDD_ReadDataReg(UART5_BASE_PTR);&lt;/P&gt;
&lt;P&gt; uart_rx_flag=0;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am NOT able to clear the interrupt asserted by the UART5.&lt;/P&gt;&lt;P&gt;I think is something related in preserving the shared registers on the stack, so something ARM related (and not Freescale related :smileygrin:). &lt;/P&gt;&lt;P&gt;But Any hint will be greatly appreciated, since currently I have NO idea on how workout this problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards, &lt;/P&gt;&lt;P&gt;Luca.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Feb 2014 16:48:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Get-a-value-outside-interrupt-uart-and-related-questions/m-p/268831#M8926</guid>
      <dc:creator>Catosh</dc:creator>
      <dc:date>2014-02-28T16:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: Get a value outside interrupt uart (and related questions)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Get-a-value-outside-interrupt-uart-and-related-questions/m-p/268832#M8927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It has nothing to do with the ARM core. It is a compiler optimization stopping the reloads of the variables. The compiler assumes the variables you are using are not modified by outside code such as Interrupt routines. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to declare the variables you are accessing in both the main loop and your interrupt function as volatile.&lt;/P&gt;&lt;P&gt;volatile char tx_data;&lt;/P&gt;&lt;P&gt;volatile char uart_tx_flag;&lt;/P&gt;&lt;P&gt;The compiler is optimizing out the loads of the variables from RAM into the cores registers. Your main loop loads the variables into a register once on startup and then never goes back to the original RAM location to reload the variables. The main loop never sees the data items change. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By making the variables volatile it will force the compiled main loop code to reload the variables from ram on every iteration of the loop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Feb 2014 18:57:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Get-a-value-outside-interrupt-uart-and-related-questions/m-p/268832#M8927</guid>
      <dc:creator>ndavies</dc:creator>
      <dc:date>2014-02-28T18:57:47Z</dc:date>
    </item>
    <item>
      <title>Re: Get a value outside interrupt uart (and related questions)</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Get-a-value-outside-interrupt-uart-and-related-questions/m-p/268833#M8928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First of all, &lt;BR /&gt;thank you very much for your reply. &lt;/P&gt;&lt;P&gt;Actually, I already declared my variables as &lt;STRONG&gt;volatile&lt;/STRONG&gt; in processorExpert.c and &lt;STRONG&gt;external volatile&lt;/STRONG&gt; in events.c; anyway they still arent' updated. BTW, using pointers I am able to work around this problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;L.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Mar 2014 07:58:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Get-a-value-outside-interrupt-uart-and-related-questions/m-p/268833#M8928</guid>
      <dc:creator>Catosh</dc:creator>
      <dc:date>2014-03-03T07:58:20Z</dc:date>
    </item>
  </channel>
</rss>

