<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: Using the CAN interface</title>
		<link>http://forums.leaflabs.com/topic.php?id=802</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Thu, 23 May 2013 03:54:50 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=802" rel="self" type="application/rss+xml" />

		<item>
			<title>pvh on "Using the CAN interface"</title>
			<link>http://forums.leaflabs.com/topic.php?id=802&amp;page=6#post-21677</link>
			<pubDate>Sun, 16 Dec 2012 08:46:04 +0000</pubDate>
			<dc:creator>pvh</dc:creator>
			<guid isPermaLink="false">21677@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hello All,&#60;/p&#62;
&#60;p&#62;I already found a solution on my question above. Just by using the &#34;read&#34; function to read received data from FIFO0.&#60;/p&#62;
&#60;p&#62;I'm sending a single CAN message from my computer via a CAN-USB adapter to the Olimex STM32. The STM32 receives the data and send it back with a different ID (0x55). The problem is not every message I send from my computer is send back by the STM32. I have to send the same message 2-3 time before the STM32 replies with ID 0x55.&#60;/p&#62;
&#60;p&#62;******&#60;br /&#62;
void loop()&#60;br /&#62;
{&#60;br /&#62;
  delay(1000);&#60;/p&#62;
&#60;p&#62;  msg.ID = 0x55;&#60;br /&#62;
  mbx = canBus.send(&#38;amp;msg);&#60;/p&#62;
&#60;p&#62;  r_msg = canBus.recv();&#60;br /&#62;
  if (r_msg != NULL)&#60;br /&#62;
  {&#60;br /&#62;
    canBus.read(CAN_FIFO0, &#38;amp;msg);&#60;br /&#62;
    canBus.release(CAN_FIFO0);&#60;br /&#62;
    canBus.free();&#60;br /&#62;
    toggleLED();&#60;br /&#62;
  }&#60;br /&#62;
}&#60;br /&#62;
******&#60;br /&#62;
Question: why is the STM32 only replying when I send a message multiple times, and not just replying on every message?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>pvh on "Using the CAN interface"</title>
			<link>http://forums.leaflabs.com/topic.php?id=802&amp;page=6#post-21669</link>
			<pubDate>Sat, 15 Dec 2012 12:10:08 +0000</pubDate>
			<dc:creator>pvh</dc:creator>
			<guid isPermaLink="false">21669@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hello, &#60;/p&#62;
&#60;p&#62;Can somebody tell me how I can read the actual CAN data (like ID and data[]) from the canBus.recv() function? &#60;/p&#62;
&#60;p&#62;Based on the code below I only get a valid pointer back that tells me I recieved new data.&#60;/p&#62;
&#60;p&#62;*********&#60;br /&#62;
void loop()&#60;br /&#62;
{&#60;br /&#62;
  mbx = canBus.send(&#38;amp;smsg);&#60;br /&#62;
  delay(1000);&#60;/p&#62;
&#60;p&#62;  r_msg = canBus.recv();&#60;/p&#62;
&#60;p&#62;  if (r_msg != NULL)&#60;br /&#62;
  {&#60;br /&#62;
    toggleLED();&#60;/p&#62;
&#60;p&#62;    canBus.free();&#60;br /&#62;
  }&#60;br /&#62;
  //canBus.end();&#60;/p&#62;
&#60;p&#62;}&#60;br /&#62;
*********
&#60;/p&#62;</description>
		</item>
		<item>
			<title>speakman on "Using the CAN interface"</title>
			<link>http://forums.leaflabs.com/topic.php?id=802&amp;page=6#post-20683</link>
			<pubDate>Wed, 31 Oct 2012 08:19:04 +0000</pubDate>
			<dc:creator>speakman</dc:creator>
			<guid isPermaLink="false">20683@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Have anyone of you tried to port this CAN additions to the current libmaple at GitHub?&#60;br /&#62;
&#60;a href=&#34;https://github.com/leaflabs/libmaple&#34; rel=&#34;nofollow&#34;&#62;https://github.com/leaflabs/libmaple&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Anonymous on "Using the CAN interface"</title>
			<link>http://forums.leaflabs.com/topic.php?id=802&amp;page=6#post-13719</link>
			<pubDate>Wed, 12 Sep 2012 09:08:16 +0000</pubDate>
			<dc:creator>Anonymous</dc:creator>
			<guid isPermaLink="false">13719@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I got it working with Maple IDE. I put the Tx interrupt in the wrong place. All is good at the moment. If someone does monitor this, I will probably have some more questions before the end of my project. Check back often or set up the RSS feed.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Anonymous on "Using the CAN interface"</title>
			<link>http://forums.leaflabs.com/topic.php?id=802&amp;page=6#post-13317</link>
			<pubDate>Fri, 07 Sep 2012 13:29:39 +0000</pubDate>
			<dc:creator>Anonymous</dc:creator>
			<guid isPermaLink="false">13317@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I am brand new to these boards. Maple and leaflabs forum. &#60;/p&#62;
&#60;p&#62;I installed the three files from x893 into the proper locations and made the reccommended changes to allow for speed changes and the interrupt modifications and I am still having some problems. My program does not loop. When I run the following code (I have been moving comments around to try new things) it will output two correct messages. It will output the message from void 1 time and the message from loop 1 time (not looping). If I put a delay anywhere before the second send, it will not send anything. I think there is a problem in the libraries or core files, but I do not know enough to get it going. Can someone help me out with this or post/link code that does work? I am using Maple IDE 0.0.12&#60;/p&#62;
&#60;p&#62;#include &#38;lt;HardwareCAN.h&#38;gt;&#60;/p&#62;
&#60;p&#62;HardwareCAN canBus(CAN1_BASE);&#60;/p&#62;
&#60;p&#62;void setup()&#60;br /&#62;
{&#60;br /&#62;
  canBus.map(CAN_GPIO_PB8_PB9);&#60;br /&#62;
  SerialUSB.end();  // Disable USB !!!&#60;/p&#62;
&#60;p&#62;  CAN_TX_MBX mbx;&#60;br /&#62;
  CanMsg t_msg;&#60;/p&#62;
&#60;p&#62;  canBus.begin(CAN_SPEED_250, CAN_MODE_NORMAL);&#60;br /&#62;
  canBus.filter(0, 0, 0);&#60;br /&#62;
  //canBus.set_pool_mode();&#60;br /&#62;
  canBus.set_irq_mode();	// use irq mode&#60;/p&#62;
&#60;p&#62;  t_msg.IDE = CAN_ID_EXT;&#60;br /&#62;
  t_msg.RTR = CAN_RTR_DATA;&#60;br /&#62;
  t_msg.ID = 0x0E55FF;&#60;br /&#62;
  t_msg.DLC = 8;&#60;br /&#62;
  t_msg.Data[0] = 0xAA;&#60;br /&#62;
  t_msg.Data[1] = 0x55;&#60;br /&#62;
  t_msg.Data[2] = 0x0;&#60;br /&#62;
  t_msg.Data[3] = 0x0;&#60;br /&#62;
  t_msg.Data[4] = 0x0;&#60;br /&#62;
  t_msg.Data[5] = 0x0;&#60;br /&#62;
  t_msg.Data[6] = 0x0;&#60;br /&#62;
  t_msg.Data[7] = 0x98;&#60;br /&#62;
  mbx = canBus.send(&#38;amp;t_msg);&#60;/p&#62;
&#60;p&#62;//  while(!canBus.fifo_ready(CAN_FIFO0))&#60;br /&#62;
//  {&#60;br /&#62;
//    delay(10);&#60;br /&#62;
//  }&#60;br /&#62;
//  canBus.read(CAN_FIFO0, &#38;amp;t_msg);&#60;br /&#62;
//  canBus.release(CAN_FIFO0);&#60;/p&#62;
&#60;p&#62;//  while(!canBus.available())&#60;br /&#62;
//  {&#60;br /&#62;
//    delay(10);&#60;br /&#62;
//  }&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;void loop()&#60;br /&#62;
{&#60;/p&#62;
&#60;p&#62;  CAN_TX_MBX mbx;&#60;br /&#62;
  CanMsg t_msg;&#60;/p&#62;
&#60;p&#62;  t_msg.Data[0] = 0xAA;&#60;br /&#62;
  t_msg.Data[1] = 0x55;&#60;br /&#62;
  t_msg.Data[2] = 0x09;&#60;br /&#62;
  t_msg.Data[3] = 0x08;&#60;br /&#62;
  t_msg.Data[4] = 0x07;&#60;br /&#62;
  t_msg.Data[5] = 0x06;&#60;br /&#62;
  t_msg.Data[6] = 0x05;&#60;br /&#62;
  t_msg.Data[7] = 0x98;&#60;br /&#62;
  mbx = canBus.send(&#38;amp;t_msg);&#60;br /&#62;
//  delay(100);&#60;/p&#62;
&#60;p&#62;}
&#60;/p&#62;</description>
		</item>
		<item>
			<title>x893 on "Using the CAN interface"</title>
			<link>http://forums.leaflabs.com/topic.php?id=802&amp;page=6#post-12427</link>
			<pubDate>Tue, 14 Aug 2012 20:20:26 +0000</pubDate>
			<dc:creator>x893</dc:creator>
			<guid isPermaLink="false">12427@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Better if implement in Maple 0.13 (or 0.14 if 0.13 skipped)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>pvh on "Using the CAN interface"</title>
			<link>http://forums.leaflabs.com/topic.php?id=802&amp;page=6#post-12424</link>
			<pubDate>Tue, 14 Aug 2012 16:09:36 +0000</pubDate>
			<dc:creator>pvh</dc:creator>
			<guid isPermaLink="false">12424@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Phono, X893,&#60;br /&#62;
the example worked for me after implementing the changes/fixes mentioned earlier in this topic. Sending/receiving between CAN monitoring device &#38;lt;-&#38;gt; Olimex-STM32 works like is should be.&#60;br /&#62;
Thanks.&#60;/p&#62;
&#60;p&#62;PS. maybe its useful to write some documentation about the use of this library in combination with Maple and publish an up-to-date example?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Phono on "Using the CAN interface"</title>
			<link>http://forums.leaflabs.com/topic.php?id=802&amp;page=6#post-12408</link>
			<pubDate>Tue, 14 Aug 2012 07:57:33 +0000</pubDate>
			<dc:creator>Phono</dc:creator>
			<guid isPermaLink="false">12408@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;@pvh : to make it cyclic, put the send command in the &#60;code&#62;loop()&#60;/code&#62; function. But first, remove the &#60;code&#62;canBus.end();&#60;/code&#62; from the &#60;code&#62;setup()&#60;/code&#62; function. I suggest to use the following function to safely send without overflowing the buffer :&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;CAN_TX_MBX CANsend(CanMsg *pmsg)
{
  CAN_TX_MBX mbx;

  do
    mbx = canBus.send(pmsg) ;
  while(mbx == CAN_TX_NO_MBX) ;
  return mbx ;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;then you can write the loop() function :&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;void loop(void)
{
  CANsend(&#38;amp;message);
  delay(100);
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;I hope this will help you.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>x893 on "Using the CAN interface"</title>
			<link>http://forums.leaflabs.com/topic.php?id=802&amp;page=5#post-12384</link>
			<pubDate>Mon, 13 Aug 2012 15:45:09 +0000</pubDate>
			<dc:creator>x893</dc:creator>
			<guid isPermaLink="false">12384@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;i use DIY j-link pro only.&#60;br /&#62;
Also i have ulink and coocox but i prefer j-link.&#60;br /&#62;
Keil as IDE (but for edit complex project better Visual Studio).
&#60;/p&#62;</description>
		</item>
		<item>
			<title>pvh on "Using the CAN interface"</title>
			<link>http://forums.leaflabs.com/topic.php?id=802&amp;page=5#post-12383</link>
			<pubDate>Mon, 13 Aug 2012 15:08:18 +0000</pubDate>
			<dc:creator>pvh</dc:creator>
			<guid isPermaLink="false">12383@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hello,&#60;br /&#62;
@ Phone: I did a quick check; the fixes worked out for me as well.&#60;br /&#62;
Message data 0xAA, 0x55 showed up in my CAN monitoring GUI.&#60;br /&#62;
The only message was only send once, is it also possible to send it cyclic?&#60;/p&#62;
&#60;p&#62;@ X893: you are right, it is quit hard to debug Maple code/libraries without debugger or print output. Which development environment do you recommend in combination with a ARM-USB-TINY-H debugger?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Phono on "Using the CAN interface"</title>
			<link>http://forums.leaflabs.com/topic.php?id=802&amp;page=5#post-12375</link>
			<pubDate>Mon, 13 Aug 2012 10:49:08 +0000</pubDate>
			<dc:creator>Phono</dc:creator>
			<guid isPermaLink="false">12375@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi X893,&#60;br /&#62;
Hi all, &#60;/p&#62;
&#60;p&#62;I finally could have the CAN work on my Olimexino board. There were a few bugs in the library I had to fix.&#60;br /&#62;
Please x893 note the following changes and if you can, amend the code on your repository.&#60;/p&#62;
&#60;p&#62;1) In USB.C, anywhere, add :&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;//  Begin Fix JMD
void USB_HP_CAN_TX_IRQHandler (void);

void __irq_usb_hp_can_tx(void)
{
  USB_HP_CAN_TX_IRQHandler () ;
}
//  End Fix JMD&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;This is the interrupt handler for the CAN TX interrupt, which was missing.&#60;/p&#62;
&#60;p&#62;Please note that this change produces errors in sketches that do not use the CAN library. X893, could you devise a way to correct this? For example using #ifdef...#endif blocks ?&#60;/p&#62;
&#60;p&#62;2) in HardwareCAN.cpp&#60;br /&#62;
change method HardwareCAN::begin as follows :&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;CAN_STATUS HardwareCAN::begin(CAN_SPEED speed, uint32 mode)
{
/*  Begin Fix JMD
	if (can_init(Port, CAN_MCR_NART, CAN_SPEED_250) == CAN_OK)
 */
	if (can_init(Port, CAN_MCR_NART, speed) == CAN_OK)
 // End Fix JMD
		return can_set_mode(Port, mode);
	return can_status();
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;This allows to choose the bit rate, that was fixed to 250k.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>x893 on "Using the CAN interface"</title>
			<link>http://forums.leaflabs.com/topic.php?id=802&amp;page=5#post-12321</link>
			<pubDate>Sat, 11 Aug 2012 18:05:19 +0000</pubDate>
			<dc:creator>x893</dc:creator>
			<guid isPermaLink="false">12321@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi pvh,&#60;br /&#62;
easy way - connect 2 olimex boards (change program on first to send data and second only receive and display), so you remove invalid timing.&#60;br /&#62;
Also you can change timing constants - after experiments with car ECU at 500kbits i change timing constants to next values&#60;/p&#62;
&#60;p&#62;	[CAN_SPEED_500]		= { .btr = (&#60;br /&#62;
		(( 3-1) &#38;lt;&#38;lt; CAN_BTR_SJW_POS) &#124;&#60;br /&#62;
		((12-1) &#38;lt;&#38;lt; CAN_BTR_TS1_POS) &#124;&#60;br /&#62;
		(( 5-1) &#38;lt;&#38;lt; CAN_BTR_TS2_POS) &#124;&#60;br /&#62;
		(CAN_CLOCK / 500000UL - 1)&#60;br /&#62;
		)},&#60;/p&#62;
&#60;p&#62;can you print first 5 canBus.send(...) results ?&#60;br /&#62;
all .send return correct mailbox number (0-2) ?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>pvh on "Using the CAN interface"</title>
			<link>http://forums.leaflabs.com/topic.php?id=802&amp;page=5#post-12319</link>
			<pubDate>Sat, 11 Aug 2012 12:46:38 +0000</pubDate>
			<dc:creator>pvh</dc:creator>
			<guid isPermaLink="false">12319@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Thanks X893, I successfully compiled and transferred the example (bxCAN) to the Olimex STM32 with Maple.&#60;/p&#62;
&#60;p&#62;I have used the example in your package to start with, but until now I do not have any results sending/receiving CAN messages from the Olimex STM32. I have changed  the mode to &#34;CAN_MODE_NORMAL&#34;, but also no results. The Olimex STM CAN interface is connected to a CANbus monitor device (2x 120 resistors, 2 meter cable in between). &#60;/p&#62;
&#60;p&#62;Does anyone has an idea what’s going wrong?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>x893 on "Using the CAN interface"</title>
			<link>http://forums.leaflabs.com/topic.php?id=802&amp;page=5#post-12301</link>
			<pubDate>Sat, 11 Aug 2012 04:01:38 +0000</pubDate>
			<dc:creator>x893</dc:creator>
			<guid isPermaLink="false">12301@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;&#60;a href=&#34;http://akb77.com/g/stm32/maplehardwarecan/&#34; rel=&#34;nofollow&#34;&#62;http://akb77.com/g/stm32/maplehardwarecan/&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>pvh on "Using the CAN interface"</title>
			<link>http://forums.leaflabs.com/topic.php?id=802&amp;page=5#post-12286</link>
			<pubDate>Fri, 10 Aug 2012 14:27:50 +0000</pubDate>
			<dc:creator>pvh</dc:creator>
			<guid isPermaLink="false">12286@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;X893, where can we find your latest hardwareCAN library for MAPLE IDE. After compiling your “bxCAN” example I get the following error:&#60;br /&#62;
************&#60;br /&#62;
C:\Users\PvH\Downloads\maple-ide-0.0.12-windowsxp32\maple-ide-0.0.12-windowsxp32\libraries\HardwareCAN\utility\can.c: In function 'can_deinit':&#60;br /&#62;
C:\Users\PvH\Downloads\maple-ide-0.0.12-windowsxp32\maple-ide-0.0.12-windowsxp32\libraries\HardwareCAN\utility\can.c:141: error: 'RCC_CAN' undeclared (first use in this function)&#60;br /&#62;
C:\Users\PvH\Downloads\maple-ide-0.0.12-windowsxp32\maple-ide-0.0.12-windowsxp32\libraries\HardwareCAN\utility\can.c:141: error: (Each undeclared identifier is reported only once&#60;br /&#62;
C:\Users\PvH\Downloads\maple-ide-0.0.12-windowsxp32\maple-ide-0.0.12-windowsxp32\libraries\HardwareCAN\utility\can.c:141: error: for each function it appears in.)&#60;br /&#62;
C:\Users\PvH\Downloads\maple-ide-0.0.12-windowsxp32\maple-ide-0.0.12-windowsxp32\libraries\HardwareCAN\utility\can.c: In function 'can_init':&#60;br /&#62;
************&#60;/p&#62;
&#60;p&#62;Thanks!
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
