Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length



Pages: [1]
  Print  
Author Topic: CAN problems on USBizi  (Read 110 times)
vin1953
Newbie
*
Posts: 3


View Profile
« on: July 06, 2010, 11:40:15 AM »

I've spent a lot of time with the CAN stuff and have found some things not working, of course if it was due to an omission on my part then let me know. To get CAN 1 to do anything, I had to access the PINSEL and PINMODE registers, enabling the device and setting the internal resistors off, to get the device to send or receive. I compared my Embedded Master running the same code to figure out what was different.

On CAN 2 things weren't so straight forward. I still had to fuss with the PINSEL and PINMODE registers, and although it seemed to work for a while (may have been my imagination) I can't get it to send anything, but it appears to receive data. On the send side the PostMessage() method returns a value that I assume is the number of successful packets, but there's nothing in the CAN2Txx registers.

Since the code runs on CAN 1 of the Embedded Master, I figured that it should run on the USBizi.

I'm running the latest SDK and firmware on both devices.

Vin...
Logged
SupportAdmin
Administrator
Hero Member
*****
Posts: 5516



View Profile WWW
« Reply #1 on: July 06, 2010, 12:01:50 PM »

Quote
I had to access the PINSEL and PINMODE registers

Why did you have to do that?! CAN should just work with no need for anything special.

CAN2 has an internal error and it is fixed in the beta firmware http://www.tinyclr.com/beta/

NEVER use register access unless absolutely necessary.
Logged
vin1953
Newbie
*
Posts: 3


View Profile
« Reply #2 on: July 06, 2010, 01:31:51 PM »

You ask why... starting from the example code that you've published a few dozen times, CAN 1 on the EM would send messages @ 125kbps and my Vector CanAlyzer would display them fine...

Same code on the "izi" nothing would show up. So started with a scope to see if there was a problem with the transceiver, nothing came out the pin... Tried to send from the CanAlyzer and I could see data at the pin on the LPC2388/USBizi, but the GetRxQueueCount was always 0... So I added some register reads to see what the low level status was on the processor, it showed me when I would try a write that there was no other device on the bus... no "ACK" bit detected. And on the read side nothing was in the regs telling me a message was received, GSR and SR didn't indicate a message was received.

So I looked at the EM, at the register level, and saw that when the channel was opened by the constructor, the bits in the PSEL and PMODE register refected what the LPC manual said was needed for the pins to be in CAN mode. I did the same test on the USBizi and at the same point in the code, the PSEL and PMODE were still wrong both were 0. When I did that by hand on the "izi" it started talking... I looked at all the CAN regs and the PSEL/PMODE were the only ones different

As for your statement that the CAN should have just worked, I agree... I thought I was chasing a transciever issue, or a problem with the interface to CanAlyzer. I eliminated the latter, using the EM and the former with a scope... That's why I asked if there was something I missed.

I'll load in the beta and see if it behaves as it should... BTW here's a wish list item, add a method to get to the 'low level' CAN error data in the ICR and the error counters from the GSR, most people wouldn't know how to interpret them but I've been able to use them on an SJA1000 (similar i'face) to diagnose sick CAN networks. I am trying to develop a low cost CAN data logger and the FEZ/USBizi chip fits well in that application. 
Logged
SupportAdmin
Administrator
Hero Member
*****
Posts: 5516



View Profile WWW
« Reply #3 on: July 06, 2010, 02:58:45 PM »

You shouldn't need to go in that direction. It is good that you are very knowledgeable and understand registers and is able to go in the processor to tweak it any way you like. But, if you want your code to be portable then you should use the official drivers and if you experience any problem then just let us know and we will help you out.

Now, let us start from zero and see if we can help you out.....no register access for now! Please try to use CAN with no register access and if it didn't work then let us know.

I am assuming that you are using the latest firmware? http://www.tinyclr.com/release-notes/
Note that CAN2 doesn't work on this firmware (it is fixed in new beta release) but CAN1 should be fine.
Logged
GHI_Support
Administrator
Hero Member
*****
Posts: 1295


View Profile
« Reply #4 on: July 06, 2010, 03:55:09 PM »

You need to do this on our Beta release because it already fixes some issues for both CAN channels...
We will send you an email with the download link.
« Last Edit: July 06, 2010, 03:57:41 PM by GHI_Support » Logged
vin1953
Newbie
*
Posts: 3


View Profile
« Reply #5 on: July 07, 2010, 08:29:53 AM »

Thanks for the assistance, the Beta works great on both CAN Channels...
If I run into anything else related to the Beta I will let you know.

Vin...
Logged
Pages: [1]
  Print  
 
Jump to: