<?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: pheripheral register access in C Code in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/pheripheral-register-access-in-C-Code/m-p/138250#M2723</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi Klaus,&lt;BR /&gt;I don't know the 56800 but I have some guesses:&lt;BR /&gt;&lt;BR /&gt;Are both, GPIO_A_DR and PORTA at the same address 0x00F101 and have the same width (8 or 16 bits)?&lt;BR /&gt;&lt;BR /&gt;Try it this way:&lt;BR /&gt;#define PORTA *(unsigned char volatile *)(0x00F101) // port A &lt;BR /&gt;The 'volatile' keyword instructs the compiler to leave out optimizations e.g. using a register instead of the memory address.&lt;BR /&gt;&lt;BR /&gt;You may also look at the compiler output (assembler code) to see what's going wrong.&lt;BR /&gt;&lt;BR /&gt;Good Luck,&lt;BR /&gt; pittbull&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Jun 2006 20:41:43 GMT</pubDate>
    <dc:creator>pittbull</dc:creator>
    <dc:date>2006-06-08T20:41:43Z</dc:date>
    <item>
      <title>pheripheral register access in C Code</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/pheripheral-register-access-in-C-Code/m-p/138249#M2722</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hallo,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I'm currently trying to become familiar with the 56800 and codewarrior but one of the simplest things is causing troubles. I was changing the LED_isr example wich is supplied with Codewarrior and tried to access the GPIO_A_DR and also some other pheripheral register directly by writing a value to it. Below you can see the definition I added to MC56F801x.h:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;#define PORTA&amp;nbsp;&amp;nbsp; (*(char*) (0x00F101))&amp;nbsp;&amp;nbsp; // port A&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;..which defines PORTA as GPIO_A_DR&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;the Main function show how I tried to write a value to PORTA which refers to GPIO_A_DR:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;void main(void)&lt;BR /&gt;{&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;init_ports();&lt;BR /&gt;init_uart();&lt;BR /&gt;while(1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;PORTA=0x00;&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;&amp;nbsp;&amp;nbsp;//doesn't work&lt;BR /&gt;&amp;nbsp;&amp;nbsp;//asm(bfset #$0001,X:GPIO_A_DR);&amp;nbsp;&amp;nbsp; //works fine&lt;BR /&gt;&amp;nbsp;&amp;nbsp;delay();&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;//asm(bfclr #$0001,X:GPIO_A_DR);&amp;nbsp;&amp;nbsp;&amp;nbsp; //works fine&lt;BR /&gt;&amp;nbsp;&amp;nbsp;delay();&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;PORTA=0xFF;&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; //doesn't work&lt;BR /&gt;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt;}&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Although I'm sure I set all the other registers concerning GPIO_A the right way (direction register ....) the values asigned to PORTA do not appear at the outputs pins of the 56F8014. Why do &amp;nbsp;assembler commands work fine while writing to PORTA (which refers to GPIO_A_DR) don't show any effects on the output pins ?&lt;/DIV&gt;&lt;DIV&gt;I also tried to write to some registers from the SCI pheripheral but I didn't succeed either...&lt;/DIV&gt;&lt;DIV&gt;All other C-Code which does'nt access the pheripheral registers works fine !&lt;/DIV&gt;&lt;DIV&gt;There must be a very fundamental problem regarding the compiler settings or something else since I cannot explain myself sucha behaviour....&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Please help !&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Klaus Pelikan&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Jun 2006 01:01:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/pheripheral-register-access-in-C-Code/m-p/138249#M2722</guid>
      <dc:creator>pelikan_tech</dc:creator>
      <dc:date>2006-06-06T01:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: pheripheral register access in C Code</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/pheripheral-register-access-in-C-Code/m-p/138250#M2723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi Klaus,&lt;BR /&gt;I don't know the 56800 but I have some guesses:&lt;BR /&gt;&lt;BR /&gt;Are both, GPIO_A_DR and PORTA at the same address 0x00F101 and have the same width (8 or 16 bits)?&lt;BR /&gt;&lt;BR /&gt;Try it this way:&lt;BR /&gt;#define PORTA *(unsigned char volatile *)(0x00F101) // port A &lt;BR /&gt;The 'volatile' keyword instructs the compiler to leave out optimizations e.g. using a register instead of the memory address.&lt;BR /&gt;&lt;BR /&gt;You may also look at the compiler output (assembler code) to see what's going wrong.&lt;BR /&gt;&lt;BR /&gt;Good Luck,&lt;BR /&gt; pittbull&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jun 2006 20:41:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/pheripheral-register-access-in-C-Code/m-p/138250#M2723</guid>
      <dc:creator>pittbull</dc:creator>
      <dc:date>2006-06-08T20:41:43Z</dc:date>
    </item>
  </channel>
</rss>

