<?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: GT16A SPI in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/GT16A-SPI/m-p/168240#M10987</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oliver, how is the project going?&lt;/P&gt;&lt;P&gt;Please let us know! :smileywink:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 17 Dec 2012 16:53:20 GMT</pubDate>
    <dc:creator>Monica</dc:creator>
    <dc:date>2012-12-17T16:53:20Z</dc:date>
    <item>
      <title>GT16A SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/GT16A-SPI/m-p/168234#M10981</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to get two GT16A MCUs to communicate via SPI, however I am not succeeding. The master is configured as shown below(SPI_Initialise), with the data sending being done in the laserComm function where Data[] is an array of unsigned char. Finally, the slave is configured as initSPI shows with the receiving done in the receiveSPI function. Any help would be appreciated!&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;void SPI_Initialise (void){ &amp;nbsp;&amp;nbsp; &amp;nbsp; SPIBR = 0x00; // SPI baud rate = 9.437184MHz&amp;nbsp; &amp;nbsp; SPIC1_SPIE&amp;nbsp; = 1; &amp;nbsp; SPIC1_SPE&amp;nbsp;&amp;nbsp; = 1; &amp;nbsp; SPIC1_SPTIE = 0;&amp;nbsp; &amp;nbsp; SPIC1_MSTR&amp;nbsp; = 1; &amp;nbsp; SPIC1_CPOL&amp;nbsp; = 0; &amp;nbsp; SPIC1_CPHA&amp;nbsp; = 1; &amp;nbsp; SPIC1_SSOE&amp;nbsp; = 0; &amp;nbsp; SPIC1_LSBFE = 0;&amp;nbsp;&amp;nbsp; &amp;nbsp; //SPIC2 = 0x00; // SPI control register 2 setup &amp;nbsp; SPIC2_MODFEN = 0; &amp;nbsp; SPIC2_BIDIROE = 0; &amp;nbsp; SPIC2_SPISWAI = 0;&amp;nbsp; &amp;nbsp; SPIC2_SPC0 = 0; } void laserComm(char Data[]){ &amp;nbsp; int i; &amp;nbsp; PTCD_PTCD6 = 0; //Pull low to select slave &amp;nbsp; PTCD_PTCD5 = 0; //Pull low to select slave &amp;nbsp; PTCD_PTCD4 = 0; //Pull low to select slave &amp;nbsp; PTCD_PTCD3 = 0; //Pull low to select slave&amp;nbsp; &amp;nbsp; for(i = 0; i&amp;lt;=dataSize; i++){//send data &amp;nbsp; while(!SPIS_SPTEF) &amp;nbsp; SPID = Data[i++]; &amp;nbsp; } &amp;nbsp; PTCD_PTCD6 = 1; &amp;nbsp; PTCD_PTCD5 = 1; &amp;nbsp; PTCD_PTCD4 = 1; &amp;nbsp; PTCD_PTCD3 = 1; }&amp;nbsp; ///////// SLAVE //////////////// void initSPI (void){&amp;nbsp; &amp;nbsp; SPIC1_SPIE = 1;&amp;nbsp;&amp;nbsp; // SPI control register 1 setup &amp;nbsp; SPIC1_SPE = 1;&amp;nbsp;&amp;nbsp;&amp;nbsp; // SPI enable &amp;nbsp; SPIC1_SPTIE = 0;&amp;nbsp; // Transmit interrupt enable &amp;nbsp; SPIC1_MSTR = 0;&amp;nbsp;&amp;nbsp; // Slave select &amp;nbsp; SPIC1_CPOL = 0;&amp;nbsp;&amp;nbsp; // Clock polarity &amp;nbsp; SPIC1_CPHA = 1;&amp;nbsp;&amp;nbsp; // Clock phase &amp;nbsp; SPIC1_SSOE = 0;&amp;nbsp;&amp;nbsp; // Slave select output enable &amp;nbsp; SPIC1_LSBFE = 0;&amp;nbsp; // LSB first disabled &amp;nbsp;&amp;nbsp; &amp;nbsp; //SPIC2 = 0x00; // SPI control register 2 setup &amp;nbsp; SPIC2_MODFEN = 0; &amp;nbsp; SPIC2_BIDIROE = 0; &amp;nbsp; SPIC2_SPISWAI = 0;&amp;nbsp; &amp;nbsp; SPIC2_SPC0 = 0; }&amp;nbsp; interrupt 15&amp;nbsp; // SPI receive interrupt&amp;nbsp;&amp;nbsp; void receiveSPI (void){ &amp;nbsp; int i;&amp;nbsp;&amp;nbsp; &amp;nbsp; for (i = 0; i&amp;lt;=dataSize; i++) &amp;nbsp; while(!SPIS_SPRF) SPIdataIn[i] = SPID;&amp;nbsp; // Wait for receive buffer flag, read data &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; SPIdataReceived = 1;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="plain" name="code"&gt;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;PRE class="c++" name="code"&gt;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;PRE class="c++" name="code"&gt;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:15:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/GT16A-SPI/m-p/168234#M10981</guid>
      <dc:creator>woohoo</dc:creator>
      <dc:date>2020-10-29T09:15:53Z</dc:date>
    </item>
    <item>
      <title>Re: GT16A SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/GT16A-SPI/m-p/168235#M10982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First of all, at leaving reset all pins are GPIO IN, w/o pullups. The chip-select signals need to be outputs.&lt;/P&gt;&lt;P&gt;If it is so, then the problem seems to be with the topology used. If I understand correctly, as you pull 4 chipselects at the same time, you 're sending data to multiple slaves. they should have the MOSI pins connected parallel, not in the daisy chain fashion, like jtag chains.If it is so, then we need further examination of the software.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Nov 2012 08:44:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/GT16A-SPI/m-p/168235#M10982</guid>
      <dc:creator>AntiGeri</dc:creator>
      <dc:date>2012-11-09T08:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: GT16A SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/GT16A-SPI/m-p/168236#M10983</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, The code I posted above is a snippet from the main body, so the initialisation of the GPIO's isn't shown. The MOSI pins are connected in parallel and still I have no luck receiving data at the slave. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One thing I did notice when running the debugger is the interrupt for the slave is not triggered. Is the vector number for the interrupt correct?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Nov 2012 14:07:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/GT16A-SPI/m-p/168236#M10983</guid>
      <dc:creator>woohoo</dc:creator>
      <dc:date>2012-11-09T14:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: GT16A SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/GT16A-SPI/m-p/168237#M10984</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One more idea, when you do the write operations on the SPIC1, and SPIC2, in your code, you do it bit by bit, and the datasheet suggests, that this would be done bytewise, in other words, something like SPIC1 |= SPIE | SPE ...&lt;/P&gt;&lt;P&gt;...anyway...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have set up an SPI master once, to receive , (I'm not a sw-expert, so please don't laugh, but) master controls look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*Some Init code for the peripherals*/&lt;BR /&gt;&amp;nbsp; SOPT = 2;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Disable WD&lt;BR /&gt;&amp;nbsp; ICGC2 = 0x08;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //10MHz Crystal -&amp;gt; 40MHz Core, 20MHz Bus&lt;BR /&gt;&amp;nbsp; ICGC1 = 0xFE;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; PTCDD = 0x08;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //PTC3 -&amp;gt; INT_ENAn(Out), PTC2 -&amp;gt; DIR_SEL(In)&lt;BR /&gt;&amp;nbsp; PTDDD = 0x08;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //PTD3 -&amp;gt; PWM(Out)&lt;BR /&gt;&amp;nbsp; PTEDD = 0x04;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //PTE2 -&amp;gt; SSn(Out)&lt;/P&gt;&lt;P&gt;&amp;nbsp; PTCD = 0x08;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Disable IRQ&lt;BR /&gt;&amp;nbsp; PTDD = 0x08;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //PWM is active low, so off&lt;BR /&gt;&amp;nbsp; PTED = 0x04;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //SSn is active low, so off&lt;/P&gt;&lt;P&gt;&amp;nbsp; SPIC1 =0x54;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Enable,Master Mode,CPHA=1&lt;BR /&gt;&amp;nbsp; SPIC2 =0x00;&lt;BR /&gt;&amp;nbsp; SPIBR =0x40;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //CLK = (BUSCLK / 5) / 2 = 1MHz&lt;/P&gt;&lt;P&gt;&amp;nbsp; TPM1SC = 0x48;&amp;nbsp;&amp;nbsp;&amp;nbsp; //TPM1 will produce timing INT (int on every 1mS)(1kHz)&lt;BR /&gt;&amp;nbsp; TPM1MODH = 0x4E;&amp;nbsp; //Set the Modulo to be 20000&lt;BR /&gt;&amp;nbsp; TPM1MODL = 0x20;&amp;nbsp; //wich is req'd for 1kHz&lt;BR /&gt;&amp;nbsp; TPM1C0VH = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //just to start up the timer&lt;BR /&gt;&amp;nbsp; TPM1C0VL = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Same reason&lt;BR /&gt;&amp;nbsp; TPM1C0SC = TPM1C1SC =&amp;nbsp; 0x00;&lt;/P&gt;&lt;P&gt;&amp;nbsp; TPM2SC = 0x08;&amp;nbsp;&amp;nbsp;&amp;nbsp; //TPM2 will be free-running PWM generator&lt;BR /&gt;&amp;nbsp; TPM2MODH = 0x3F;&amp;nbsp; //Set the Modulo to be 16383&lt;BR /&gt;&amp;nbsp; TPM2MODL = 0xFF;&amp;nbsp; //wich is req'd for 14bit res&lt;BR /&gt;&amp;nbsp; TPM2C0SC = 0x24;&amp;nbsp; //Low True Pulses&amp;nbsp; &lt;BR /&gt;&amp;nbsp; TPM2C0VH = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Off for now...&lt;BR /&gt;&amp;nbsp; TPM2C0VL = 0;&lt;BR /&gt;&amp;nbsp; EnableInterrupts; /* enable interrupts */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...and in the interrupt routine, i give dummy bytes to the spi, to start transfer, but I only need the received bytes, anyway I suppose the sent bytes are out also...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;PTED = 0x00;&amp;nbsp;&amp;nbsp; //Set SSn low,&lt;BR /&gt;for (aB = 0; aB &amp;lt; 2; aB++){ //Do it twice...&lt;BR /&gt;&amp;nbsp; SPID = 0xFF;&amp;nbsp; //&amp;nbsp; Put 0xFF to SPID&lt;/P&gt;&lt;P&gt;&amp;nbsp; bB = 0;//&amp;nbsp; Wait for transfer to end&lt;BR /&gt;&amp;nbsp; while (!(bB)) bB = (SPIS &amp;amp; 0x80);&lt;/P&gt;&lt;P&gt;&amp;nbsp; SPIDataW = SPIDataW &amp;lt;&amp;lt; 8;&lt;BR /&gt;&amp;nbsp; SPIDataW += SPID; //&amp;nbsp; Get the data from the SPID&lt;BR /&gt;};//...Until this line&lt;BR /&gt;PTED |= 0x04;&amp;nbsp;&amp;nbsp; //Set SSn high&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;This is how I handled the master, without irq unfortunately, but show some things...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;Another question:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;Could you confirm with an oscilloscope, that during transmission, data, and clk lines are toggling, or they are idle?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;this can guide us towards finding the problem.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 10 Nov 2012 10:31:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/GT16A-SPI/m-p/168237#M10984</guid>
      <dc:creator>AntiGeri</dc:creator>
      <dc:date>2012-11-10T10:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: GT16A SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/GT16A-SPI/m-p/168238#M10985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Oliver,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There seems to be a couple of issues with your master function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;void laserComm( char Data[])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;{&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; int i;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; PTCD_PTCD6 = 0; // Pull low to select slave&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; PTCD_PTCD5 = 0; // Pull low to select slave&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; PTCD_PTCD4 = 0; // Pull low to select slave&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; PTCD_PTCD3 = 0; // Pull low to select slave&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; for( i = 0; i &amp;lt;= dataSize; i++) { // send data&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while( !SPIS_SPTEF)&amp;nbsp; SPID = Data[i++];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; PTCD_PTCD6 = 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; PTCD_PTCD5 = 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; PTCD_PTCD4 = 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; PTCD_PTCD3 = 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The state of the flag SPIS_SPTEF is high when ready to send data, and goes low whenever the buffer is full.&amp;nbsp; You are attempting to send the data when the flag is low.&amp;nbsp; This condition can never occur within your code.&amp;nbsp; The second problem is that you are potentially going to set the SS signals high before final byte tranfer has finished.&amp;nbsp; To determine completion of transfer, you need to wait until the SPIS_SPRF flag is set. The corrected code follows -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;void laserComm( char Data[])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;{&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; int i;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; PTCD_PTCD6 = 0; // Pull low to select slave&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; PTCD_PTCD5 = 0; // Pull low to select slave&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; PTCD_PTCD4 = 0; // Pull low to select slave&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; PTCD_PTCD3 = 0; // Pull low to select slave&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; for( i = 0; i &amp;lt;= dataSize; i++) { &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while( !SPIS_SPTEF);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Wait until ready to send&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SPID = Data[i++];&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // send data byte&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while( !SPIS_SPRF);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Wait until transfer is complete&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (void)SPID;&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; // Clear flag&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; PTCD_PTCD6 = 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; PTCD_PTCD5 = 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; PTCD_PTCD4 = 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; PTCD_PTCD3 = 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker" style="font-family: courier new,courier;"&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker" style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;The slave function also has some issues.&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="mce_paste_marker" style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;I notice that you have a wait condition within your ISR code while you attempt to receive multiple bytes.&amp;nbsp; It is normal to process only a single byte for each interrupt, to keep the ISR duration as short as possible.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker" style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker" style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;You are also attempting to read the data when the flag is clear, and the transfer is incomplete.&amp;nbsp; The interrupt will occur when the flag becomes set.&amp;nbsp; You must clear the flag before exiting the ISR.&amp;nbsp; There does seem to be a misunderstanding about the functionality of the flags.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker" style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker" style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;The byte counter will need to be a static or global variable defined outside of the ISR function, and this will need to be initialised prior to each sequence.&amp;nbsp; You will probably need to sense the state of the SS signal to determine when initialisation should occur.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker" style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker" style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker" style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;Mac&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker" style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Nov 2012 17:25:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/GT16A-SPI/m-p/168238#M10985</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2012-11-20T17:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: GT16A SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/GT16A-SPI/m-p/168239#M10986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Oliver,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following untested code provides an example of the SPI slave process, using interrupts.&amp;nbsp; I have assumed that the GPIO pin PTCD4 is paralleled with the SS pin (PTE2), for sensing the SS state.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;#define SS_sig&amp;nbsp; PTCD_PTCD4&amp;nbsp;&amp;nbsp;&amp;nbsp; // Additional input pin paralleled with SS&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;// Static variables:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;static byte SPIdataIn[dataSize];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;static byte count = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;byte Wait_for_SPIdata( void)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; byte c;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; if (SS_sig)&amp;nbsp; return 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // No data transfer yet&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; while (!SS_sig);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Wait for completion of transfer sequence&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; c = count;&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; // Number of bytes transferred&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; count = 0;&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; // Ready for next sequence&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; return c;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;// SPI receive interrupt&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;interrupt 15 void receiveSPI( void)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;{&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; (void)SPIS;&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; // Commence clear flag&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; SPIdataIn[count++] = SPID;&amp;nbsp; // Read data&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Nov 2012 18:28:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/GT16A-SPI/m-p/168239#M10986</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2012-11-20T18:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: GT16A SPI</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/GT16A-SPI/m-p/168240#M10987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oliver, how is the project going?&lt;/P&gt;&lt;P&gt;Please let us know! :smileywink:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Dec 2012 16:53:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/GT16A-SPI/m-p/168240#M10987</guid>
      <dc:creator>Monica</dc:creator>
      <dc:date>2012-12-17T16:53:20Z</dc:date>
    </item>
  </channel>
</rss>

