<?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: MC9S12C32 to drive MMA7455L freescale accelerometer in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12C32-to-drive-MMA7455L-freescale-accelerometer/m-p/164576#M5314</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;In this line:&lt;/P&gt;&lt;PRE&gt;if( (PTT &amp;amp; 0x08) &amp;gt; 0) //if the Serial Data&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;use PTIT - the input port register. PTT read returns the status&lt;/P&gt;&lt;P&gt;of this register as output.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;ipa&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Oct 2020 09:11:20 GMT</pubDate>
    <dc:creator>ipa</dc:creator>
    <dc:date>2020-10-29T09:11:20Z</dc:date>
    <item>
      <title>MC9S12C32 to drive MMA7455L freescale accelerometer</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12C32-to-drive-MMA7455L-freescale-accelerometer/m-p/164574#M5312</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello. im trying to drive mma7455l accelerometer with a csm12c32 dev. board( has mc9s12c32 micrprocessor on it). i couldnt manage to use spi module somehow. and now im trying to use gpio pins to communicate with accelerometer. i have another problem now. i cannot write a r/w register of accelerometer but i can read register values. here is my source code to communicate through gpio pins:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&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 CS_HIGH&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ( PTT = PTT | 0x01) //|0000|0001| #define CS_LOW&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ( PTT = PTT &amp;amp; 0xFE) //|1111|1110|#define SCL_HIGH&amp;nbsp;&amp;nbsp;&amp;nbsp; ( PTT = PTT | 0x02) //|0000|0010|#define SCL_LOW&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ( PTT = PTT &amp;amp; 0xFD) //|1111|1101|#define SDO_HIGH&amp;nbsp;&amp;nbsp;&amp;nbsp; ( PTT = PTT | 0x04) //|0000|0100|#define SDO_LOW&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ( PTT = PTT &amp;amp; 0xFB) //|1111|1011|unsigned char val=0;void main(void);void initSPI(void);void Delay10TCY();void Delay10KTCYx(int i);unsigned char ReadSPI(unsigned char address);void WriteSPI(unsigned char address, unsigned char data);unsigned char SPI_RByte(void);void SPI_WByte(unsigned char data);&amp;nbsp; void main(void) {&amp;nbsp;&amp;nbsp;&amp;nbsp; EnableInterrupts;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DDRA = 0x01;&amp;nbsp;&amp;nbsp;&amp;nbsp; DDRB = 0x10;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORTA = 0x01;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORTB = 0x10;&amp;nbsp;&amp;nbsp;&amp;nbsp; initSPI();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(;;){&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; val=0; // reset value&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORTA = 0x01; // turn LED OFF&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Set up MMA7455L operation mode by writing to hex addr 16, hex value 05 (2g, 4 wires)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WriteSPI(0x16,0x05);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Delay10KTCYx(100);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; val = ReadSPI(0x16);// read value back from register and if expected value turn ON the LED&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(val==0x05){&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORTA = 0x00;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }// turn LED ON&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORTA = 0x01;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }// turn LED OFF&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; Delay10KTCYx(100);&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; if(PORTB == 0x00)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORTB = 0x10;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORTB = 0x00;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }}void initSPI(void){ DDRT = 0x07; //|0000|0111| CS_HIGH; SDO_LOW; SCL_LOW;}void Delay10TCY(){ int x; for(x=0;x&amp;lt;255;x++){}}void Delay10KTCYx(int i){ int x; for(x=0;x&amp;lt;i;x++){&amp;nbsp; Delay10TCY(); }&amp;nbsp;&amp;nbsp; }void SPI_WByte(unsigned char data){ char x; for(x=0;x&amp;lt;8;x++){ //Loop 8 bits&amp;nbsp; SCL_LOW; //Clock Low&amp;nbsp; Delay10TCY();&amp;nbsp; SDO_LOW;&amp;nbsp; if((data &amp;amp; 0x80) &amp;gt; 0)//Clear entire byte except bit 7 and check if byte is greater than 0&amp;nbsp;&amp;nbsp; SDO_HIGH; //Set the Data Out to HIGH&amp;nbsp;&amp;nbsp;&amp;nbsp; Delay10TCY(); //Delay 5uS&amp;nbsp; SCL_HIGH; //Clock High&amp;nbsp; Delay10TCY(); //Delay 5uS&amp;nbsp; data &amp;lt;&amp;lt;= 1; //Shift data bit out to the right } Delay10TCY(); //Delay 5uS}unsigned char SPI_RByte(void){ char x,data; for(x=0;x&amp;lt;8;x++){ //Loop 8 bits&amp;nbsp; SCL_LOW; //Clock Low&amp;nbsp; Delay10TCY(); //5uS delay&amp;nbsp; data &amp;lt;&amp;lt;= 1; //Shift 1 bit to the left&amp;nbsp; data &amp;amp;= 0xFE; //Clear BIT 0 from byte without touching the rest&amp;nbsp; if( (PTT &amp;amp; 0x08) &amp;gt; 0) //if the Serial Data In is HIGH do below if not then leave it 0&amp;nbsp;&amp;nbsp; data |= 1; //OR in a 1 into out byte&amp;nbsp; SCL_HIGH; //Clock High&amp;nbsp; Delay10TCY(); //5uS delay } Delay10TCY(); //Delay 5uS return data; //return our data}void WriteSPI(unsigned char address, unsigned char data){ SCL_HIGH; //Clock High CS_LOW; //Chip Select Low address = ( ( ( address &amp;lt;&amp;lt; 1 ) &amp;amp; 0x7F ) | 0x80 );&amp;nbsp; SPI_WByte(address); //Write our address SPI_WByte(data); //Write our data CS_HIGH; //Chip Select High}unsigned char ReadSPI(unsigned char address){ unsigned char tmp; SCL_HIGH; //Clock High CS_LOW; //Chip Select Low address=( ( address &amp;lt;&amp;lt; 1 ) &amp;amp; 0x7f );//Send read command together with reg address SPI_WByte(address); //Write our address to read from tmp = SPI_RByte(); //Get the byte from the device CS_HIGH; //Chip Select High return tmp; //Return tmp}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is there any thing wrong with src? i need a help very badly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ps: if anyone has a tested &amp;amp; working source code using spi module to share, that would be great too.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a good day&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by Ersancan on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2010-01-02&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;05:17 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by Ersancan on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2010-01-02&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;05:29 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:11:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12C32-to-drive-MMA7455L-freescale-accelerometer/m-p/164574#M5312</guid>
      <dc:creator>Ersancan</dc:creator>
      <dc:date>2020-10-29T09:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S12C32 to drive MMA7455L freescale accelerometer</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12C32-to-drive-MMA7455L-freescale-accelerometer/m-p/164575#M5313</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&amp;nbsp; by the way, i forgot to mention how i am sure about i can read registers. there is a register that keeps i2c address of the accelerometer. register address is 0x0D and value is 0x1D. i switch on a led if i read 1D value from 0D address.&amp;nbsp;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by Ersancan on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2010-01-02&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;11:47 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 03 Jan 2010 07:46:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12C32-to-drive-MMA7455L-freescale-accelerometer/m-p/164575#M5313</guid>
      <dc:creator>Ersancan</dc:creator>
      <dc:date>2010-01-03T07:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S12C32 to drive MMA7455L freescale accelerometer</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12C32-to-drive-MMA7455L-freescale-accelerometer/m-p/164576#M5314</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;In this line:&lt;/P&gt;&lt;PRE&gt;if( (PTT &amp;amp; 0x08) &amp;gt; 0) //if the Serial Data&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;use PTIT - the input port register. PTT read returns the status&lt;/P&gt;&lt;P&gt;of this register as output.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;ipa&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:11:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12C32-to-drive-MMA7455L-freescale-accelerometer/m-p/164576#M5314</guid>
      <dc:creator>ipa</dc:creator>
      <dc:date>2020-10-29T09:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S12C32 to drive MMA7455L freescale accelerometer</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12C32-to-drive-MMA7455L-freescale-accelerometer/m-p/164577#M5315</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks for reply. but i couldnt see if this makes a difference. forgive me if i become blind by looking at the same code for over one week.&lt;/P&gt;&lt;P&gt;anyways i replaced PTT with PTIT and nothing changed. register read operation already works fine.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jan 2010 06:15:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12C32-to-drive-MMA7455L-freescale-accelerometer/m-p/164577#M5315</guid>
      <dc:creator>Ersancan</dc:creator>
      <dc:date>2010-01-05T06:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S12C32 to drive MMA7455L freescale accelerometer</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12C32-to-drive-MMA7455L-freescale-accelerometer/m-p/164578#M5316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Look for AN3468 and the correspoding software package - there is already&lt;/P&gt;&lt;P&gt;a software example.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;ipa&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jan 2010 14:01:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12C32-to-drive-MMA7455L-freescale-accelerometer/m-p/164578#M5316</guid>
      <dc:creator>ipa</dc:creator>
      <dc:date>2010-01-05T14:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S12C32 to drive MMA7455L freescale accelerometer</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12C32-to-drive-MMA7455L-freescale-accelerometer/m-p/164579#M5317</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ersancan,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I looked into MMA7455 datasheet and it seems your code doesn't agree with SPI timing diagrams. At least clock polarity is reversed. Clock should idle low, while in your code I see it idling high. You initiate write transfer setting clock high, then setting CS low. But CS bit is not only SPI slave select, it also switches MMA chip from/to&amp;nbsp;IIC and SPI modes. I think you should make clock idling low, so that when you set CS low, clock is also low. Then you also will need to modify SPI_Write and SPI_Read routines. in SPI_Write you should first set up MMA SDI line, then pulse clock high then low. Read seems to be the similar: sample MMA SDO pin, then pulse clock high then low. Or maybe set clock high, sample SDO, then set clock low.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jan 2010 16:23:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12C32-to-drive-MMA7455L-freescale-accelerometer/m-p/164579#M5317</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2010-01-05T16:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S12C32 to drive MMA7455L freescale accelerometer</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12C32-to-drive-MMA7455L-freescale-accelerometer/m-p/164580#M5318</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;In my experience, 95% of all SPI problems are indeed solved by RTFM &lt;IMG alt=":smileyhappy:" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-happy.gif" title="Smiley Happy" /&gt;&lt;BR /&gt;&lt;BR /&gt;There is no SPI standard as such, silicon manufacturers implement SPI (or whatever they choose to call it) in a completely arbitrary manner.&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by Lundin on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2010-01-05&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;11:36 AM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jan 2010 18:35:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/MC9S12C32-to-drive-MMA7455L-freescale-accelerometer/m-p/164580#M5318</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2010-01-05T18:35:19Z</dc:date>
    </item>
  </channel>
</rss>

