<?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: 56F8037 CAN TX problems in Classic/Legacy CodeWarrior</title>
    <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/56F8037-CAN-TX-problems/m-p/150632#M2048</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi again everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Well, I have figured out what was wrong with my code. A hilarious oversight on my part.&lt;/P&gt;&lt;P&gt;Anyway, for those who might happen to have a similar problem in the future, dont forget to wait and&lt;/P&gt;&lt;P&gt;see if your send buffers are actually empty...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the send_Can_pkt routine, I had the line:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; // Select the next available TX buffer&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;txbuff = ioctl(MSCAN, MSCAN_SELECT_NEXT_TXBUFF, NULL);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This returns 0 if no buffers are found to be ready. Of course none were found after transmitting 3 blocks of data, so it merrily&lt;/P&gt;&lt;P&gt;returned zero, and would then skip over the if statement and re-enable the TX irq. Which would send the same 3 blocks again.&lt;/P&gt;&lt;P&gt;As a temporary solution, I have used:&lt;/P&gt;&lt;P&gt;while(ioctl(MSCAN, MSCAN_SELECT_NEXT_TXBUFF, NULL) == 0) {&lt;/P&gt;&lt;P&gt;// do nothing&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;// now populate buffers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works for testing, but opens up the possibility to get stuck in an endless loop, waiting for a buffer to become available.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now Im off to find a solution for that!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bye&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 19 Apr 2012 14:08:22 GMT</pubDate>
    <dc:creator>Law</dc:creator>
    <dc:date>2012-04-19T14:08:22Z</dc:date>
    <item>
      <title>56F8037 CAN TX problems</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/56F8037-CAN-TX-problems/m-p/150631#M2047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having a bit of trouble with the MSCAN module in the 56F8037. In particular, I am currently trying to get it to transmit data.&lt;/P&gt;&lt;P&gt;I have this sort of working, in that I can transmit data ok at various speeds and recieve it on my PC but I am having trouble with sending more than 3 lots of data and I think it is related to the transmit buffers.&lt;/P&gt;&lt;P&gt;For example, I have set up my controller to just send some static data over the CAN module to test if it was working. This was something like: (I populated all bytes in between - they are just omitted for clarity)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;outData[0] = 11;&amp;nbsp; to outData[7] = 18;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Populate tx data&lt;/P&gt;&lt;P&gt;can_Send_Pkt(outData, toID, fromID);&amp;nbsp;&amp;nbsp; // Send it off&lt;/P&gt;&lt;P&gt;outData[0] = 21;&amp;nbsp; to outData[7] = 28;&lt;/P&gt;&lt;P&gt;can_Send_Pkt(outData, toID, fromID);&lt;/P&gt;&lt;P&gt;outData[0] = 31;&amp;nbsp; to outData[7] = 38;&lt;/P&gt;&lt;P&gt;can_Send_Pkt(outData, toID, fromID);&lt;/P&gt;&lt;P&gt;outData[0] = 41;&amp;nbsp; to outData[7] = 48;&lt;/P&gt;&lt;P&gt;can_Send_Pkt(outData, toID, fromID);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And so on, up to 71,...,78.&lt;/P&gt;&lt;P&gt;All I recieve on the other end of the CAN bus is the data from&lt;/P&gt;&lt;P&gt;11,...,18&lt;/P&gt;&lt;P&gt;21,...,28&lt;/P&gt;&lt;P&gt;31,...,38&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And it will just keep repeating this. (ie 11, 12, 13, 14, 16, 17, 18)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems as though I can write to the tx data buffer once, then that is all. The datasheet says that the only way to clear out a tx data buffer is by writing to it. I do think something is screwy in the way I am putting data into the tx Buffers and I also think my selection of TX buffer is a bit suspect, but I cannot put my finger on it.&lt;/P&gt;&lt;P&gt;I wonder if anyone could take a quick look at my code below and see if they can see something I cannot.&lt;/P&gt;&lt;P&gt;The code is based on the Quickstart example and some other stuff I lifted from the depths of the Codewarrior directory.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have included 2 versions of my testing code below. The top one gives the above results. The bottom one just transmits one register. I believe the bottom one is a step in the right direction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1st try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;// ------------------------------------------------ CAN - TX READY ISR -----------------------------------&lt;BR /&gt;#pragma interrupt on&lt;BR /&gt;void CAN_TxRdy_ISR(void) &amp;nbsp;&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // what tx buffers are empty? &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; UWord16 tint = ioctl(MSCAN, MSCAN_READ_TINT_FLAGS, NULL);&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;// AVailable buffers&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // disable interrupts handled&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ioctl(MSCAN, MSCAN_TINT_DISABLE, tint);&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;}&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;#pragma interrupt off&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;static void send_CAN_Pkt(UWord16 outMode, UWord16 txCmd, UWord16 outID, UWord16* sndData) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;static UWord32 outIdCAN;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;static UWord16 txbuff;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;// Select the next available TX buffer&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;txbuff = ioctl(MSCAN, MSCAN_SELECT_NEXT_TXBUFF, NULL);&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if(txbuff) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;// Pointer to TX buffer&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;register UWord16* pdT = ioctl(MSCAN_TB, MSCANMB_GET_DATAPTR, NULL);&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;pdT[0] = sndData[0];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;pdT[1] = sndData[1];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;pdT[2] = sndData[2];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;pdT[3] = sndData[3];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;pdT[4] = sndData[4];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;pdT[5] = sndData[5];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;pdT[6] = sndData[6];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;pdT[7] = sndData[7];&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outID = ((ecID &amp;lt;&amp;lt; 4) &amp;amp; FROM_MASK) | (outMode &amp;lt;&amp;lt; 8);&amp;nbsp;&amp;nbsp; &amp;nbsp;// (1 &amp;lt;&amp;lt; 8) is the Mode part. Change to (Mode &amp;lt;&amp;lt; 8)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ioctl(MSCAN_TB, MSCANMB_SET_ID, outID);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ioctl(MSCAN_TB, MSCANMB_SET_LEN, 8);&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // transmit buffer&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ioctl(MSCAN, MSCAN_TRANSMIT, txbuff); &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // enable tx-finished interrupt&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ioctl(MSCAN, MSCAN_TINT_ENABLE, txbuff);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;}&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;P&gt;-------------------------&lt;/P&gt;&lt;P&gt;2nd try&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// ------------------------------------------------ CAN - TX READY ISR -----------------------------------&lt;BR /&gt;#pragma interrupt on&lt;BR /&gt;void CAN_TxRdy_ISR(void) &amp;nbsp;&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;register UWord16 txbNum;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;register UWord16 bflag;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; UWord16 tEmpty = ioctl(MSCAN, MSCAN_READ_TINT_FLAGS, NULL);&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;// AVailable buffers&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;for (txbNum=0; txbNum&amp;lt;3; txbNum++) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; register UWord16* pdT = ioctl(MSCAN_TB, MSCANMG_GET_DATAPTR, NULL);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;bflag = 1 &amp;lt;&amp;lt; txbNum;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if(ioctl(MSCAN, MSCAN_SELECT_TXBUFF, bflag)){&amp;nbsp; // Is the current buffer empty?&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;pdT[0] = outData[0];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;pdT[1] = outData[1];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;pdT[2] = outData[2];&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;// outData is defined up top as a global var for now.&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;pdT[3] = outData[3];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;pdT[4] = outData[4];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;pdT[5] = outData[5];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;pdT[6] = outData[6];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;pdT[7] = outData[7];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;ioctl(MSCAN, MSCAN_TRANSMIT, bflag);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;tEmpty &amp;amp;= ~bflag;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;// this buffer is no longer empty&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // disable interrupts handled&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ioctl(MSCAN, MSCAN_TINT_DISABLE, tEmpty);&lt;BR /&gt;}&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;#pragma interrupt off&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;//-------------------------------------&lt;BR /&gt;static void send_CAN_Pkt(UWord16 outMode, UWord16 txCmd, UWord16 outID, UWord16* sndData) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;static UWord32 outIdCAN;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;static UWord16 txbuff;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;outData[0] = sndData[0];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;outData[1] = sndData[1];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;outData[2] = sndData[2];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;outData[3] = sndData[3];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;outData[4] = sndData[4];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;outData[5] = sndData[5];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;outData[6] = sndData[6];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;outData[7] = sndData[7];&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;outID = ((ecID &amp;lt;&amp;lt; 4) &amp;amp; FROM_MASK) | (outMode &amp;lt;&amp;lt; 8);&amp;nbsp;&amp;nbsp; &amp;nbsp;// (1 &amp;lt;&amp;lt; 8) is the Mode part. Change to (Mode &amp;lt;&amp;lt; 8)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;ioctl(MSCAN_TB, MSCANMB_SET_ID, outID);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;ioctl(MSCAN_TB, MSCANMB_SET_LEN, 8);&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;// just 8 bytes at the moment&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;ioctl(MSCAN, MSCAN_TINT_ENABLE, MSCAN_TXEMPTY_ALL);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Enable the interrupt&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;}&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apologies for the wall of text....&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Laurence M&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Apr 2012 16:53:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/56F8037-CAN-TX-problems/m-p/150631#M2047</guid>
      <dc:creator>Law</dc:creator>
      <dc:date>2012-04-02T16:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: 56F8037 CAN TX problems</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/56F8037-CAN-TX-problems/m-p/150632#M2048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi again everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Well, I have figured out what was wrong with my code. A hilarious oversight on my part.&lt;/P&gt;&lt;P&gt;Anyway, for those who might happen to have a similar problem in the future, dont forget to wait and&lt;/P&gt;&lt;P&gt;see if your send buffers are actually empty...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the send_Can_pkt routine, I had the line:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; // Select the next available TX buffer&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;txbuff = ioctl(MSCAN, MSCAN_SELECT_NEXT_TXBUFF, NULL);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This returns 0 if no buffers are found to be ready. Of course none were found after transmitting 3 blocks of data, so it merrily&lt;/P&gt;&lt;P&gt;returned zero, and would then skip over the if statement and re-enable the TX irq. Which would send the same 3 blocks again.&lt;/P&gt;&lt;P&gt;As a temporary solution, I have used:&lt;/P&gt;&lt;P&gt;while(ioctl(MSCAN, MSCAN_SELECT_NEXT_TXBUFF, NULL) == 0) {&lt;/P&gt;&lt;P&gt;// do nothing&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;// now populate buffers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works for testing, but opens up the possibility to get stuck in an endless loop, waiting for a buffer to become available.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now Im off to find a solution for that!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bye&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Apr 2012 14:08:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/56F8037-CAN-TX-problems/m-p/150632#M2048</guid>
      <dc:creator>Law</dc:creator>
      <dc:date>2012-04-19T14:08:22Z</dc:date>
    </item>
  </channel>
</rss>

