C_can api

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

C_can api

1,808 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rcazalis on Wed Aug 18 12:00:01 MST 2010
Hi,

I started to write my own CAN functions (init, send and receive) but realised there was built-in functions in ROM.
It makes sense to use those.

I've noticed some contradictions in the LPC11C14 datasheet around the C_CAN API.
On page 223 it says the init_can() function has 1 argument whereas on the 4th line of following page it gives 2... which one is correct?

Has anyone got this running?
Is there more detailed explainations somewhere about this API? I must admit I struggle a bit to understand how it works...

Thanks in advance.
0 Kudos
Reply
8 Replies

1,775 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by igorsk on Fri Sep 17 09:54:17 MST 2010
Someone posed this to the lpc2000 group, supposedly from NXP support:

Quote:
The correct declaration of the ROM typedef struct is:
typedef struct _ROM {
  const unsigned p_usbd;
  const unsigned p_clib;
#ifdef CANROMD_PRESENT
  const CAND * pCAND;
#else
  const unsigned pCAND;
#endif /* CANROMD_PRESENT */
  const unsigned p_pwrd;
  const unsigned p_dev1;
  const unsigned p_dev2;
  const unsigned p_dev3;
  const unsigned p_dev4;
}  ROM;



Example code provided by NXP Tech support works with the on-chip drivers correctly to TX and RX CAN messages.

0 Kudos
Reply

1,775 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by igorsk on Fri Aug 20 07:15:08 MST 2010
I don't have the chip and I know very little about CAN, sorry :) From the manual it seems that the ROM interface is intended to be very simple and handles errors etc by itself. If you want fine-grained control you'll probably have to use direct HW interface.
0 Kudos
Reply

1,775 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rcazalis on Fri Aug 20 06:03:34 MST 2010
Sorry, you are right, it does compile but I still get confused by the API functions.
For example how do you control MSGVAL to set a message as valid or to invalidate one?
To me a message configuration needs ARB (32 bits), MASK (32 bits), CTRL (16 bits) and a message number (1 to 32).
CMDMASK could be set to all ones at worst.
Still some parameters are missing in the command.

I think it is poorly documented but NXP's support doesn't seem to have an answer...:D

Thanks again for your help. Do you have the CAN working on an 11C14?
0 Kudos
Reply

1,775 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by igorsk on Fri Aug 20 04:50:21 MST 2010
Why do you say "ROM is not defined"? I have the definition right there in my post.
0 Kudos
Reply

1,775 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rcazalis on Fri Aug 20 04:13:12 MST 2010
Thanks Igorsk for your help.

As ROM is not defined it still doesn't work, but I've changed path: I've written my own commands as it is easy enough and I fully control what's happening.
Said that, nothing happens :(
Has anyone managed to get the CAN running on the 11C14?

I've just done an INIT and then call a SEND, but nothing comes out on the pins...
0 Kudos
Reply

1,775 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by igorsk on Thu Aug 19 03:23:53 MST 2010
From a quick glance at the UM, I _think_ it is something like this:
typedef struct _ROM
{
  CAND *pCAND;
  // other pointers TBD
} ROM;

And the single mention of "pCANAPI" should be replaced by "pCAND". I can't be sure about the init_can function but most likely it accepts one argument. However, passing it two arguments will not break anything, so you could just do that.
If someone sends me a ROM dump I'll be able to say for sure
0 Kudos
Reply

1,775 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Thu Aug 19 02:45:08 MST 2010
The error is because ROM is not defined. I've looked the the UM and there is no definition for ROM...

Perhaps somebody from NXP can comment/provide the definition, and comment on the original question?
0 Kudos
Reply

1,775 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rcazalis on Wed Aug 18 13:23:25 MST 2010
Hi again,

by the way, I've inserted all the C_CAN API code examples that is in the LPC11C14 user manual but I get an error message on:
ROM **rom = (ROM **)0x1fff1ff8UL;

Error message is:
Invoking: MCU C Compiler
arm-none-eabi-gcc -D__USE_CMSIS=CMSISv1p30_LPC11xx -DDEBUG -D__CODE_RED -D__REDLIB__ -I"C:\Documents and Settings\User\My Documents\lpcxpresso_3.4\workspace\CMSISv1p30_LPC11xx\inc" -O0 -g3 -Wall -c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -Wa,-ahlnds=main.asm -mcpu=cortex-m0 -mthumb -MMD -MP -MF"src/main.d" -MT"src/main.d" -o"src/main.o" "../src/main.c"
../src/main.c:77: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
0 Kudos
Reply