FlexCAN 5282 Initialization

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

FlexCAN 5282 Initialization

2,713 Views
NetGhost
Contributor I
Hi..
 
Already looked in this forum for some kind of initialization for FlexCAN interface in 5282 EVB.
 
The board I', using is somekind of 5282evb with some changes like 80Mhz Clock ram and flash size.
 
Concerning FlexCAN interface it's quite equal to evb's one.
 
Already read some stuff concerning this interface, 5282 manual, and tryed to use coldfire init as suggested in this forum.
 
Got something working, but nothing to be seen.
 
I configure all the registers, configure buffer 0 for TX and buffer 1 for RX, and both working with interrupts.
 
The fact is that when I try to send something in buffer 0, I get nothing else but errors in CAN error registry, and the message never leaves the buffer.
 
I guess it tries to send it forever but with out success.
 
Can anyone just give me some small initialization code that put it working somewhere else?
 
This way I can check what I'm doing wrong and put this to work...
 
With my best thanks in advance
 
Paulo
Labels (1)
0 Kudos
4 Replies

453 Views
Pai
Contributor I
Hi,
At Frescale site, on MCF5282 page, look for "MCF5282SC.zip" - it contains an example for FlexCan initialization (in the folder 'fat' - factory acceptance test).
Regards,
Pai
0 Kudos

453 Views
NetGhost
Contributor I
Thanks for your answer.
It was a litle bit usefull. At least I saw that my code is not very wrong...:smileywink:
But, in a way it was not usefull because it just tests the interface internally.
 
At the moment what I'm trying to do is to send a frame from buffer 0 to the bus. I don't mind if no one is there to get it. Just send the frame and receive an interrupt telling me that my frame was sent.
 
I configured buffer 0 for this. I write data on it in the same way as the example does.
buffer 0 code/length = 0xC8 this means send the frame once unconditionally isn't it?
 
What I can see on the scope is that the frame keeps on getting sent and I never receive the interrupt telling me it was sent.
After a while if I see on buffer 0 code length register I get 0xC8 when, if the frame was sent I whould have there something like 0x8X wasn't it?
 
If you think it's usefull  to give me some help I can post here my code for you to analise...
 
BRegards
 
Paulo
0 Kudos

453 Views
krsihna1234
Contributor I
Hi,
 
   I am new to CAN.   I am having few doubts regarding CAN drivers. Please help me regarding this.The questions related here are based on the can.zip provided by Mr.David.
 
PLease refer can.zip for below questions.
 
 
1. can you explain the below structure how you got the values.
 
FileName :- can_init.c
 
can_SpeedParam_t can_SpeedParam[] = {
 {125000, 15, 16, 3, 8, 4, 2, 0,  1},
 {250000, 7, 16, 3, 8, 4, 2, 0,  1},
 {500000, 3, 16, 8, 5, 2, 2, 0,  1},
 {800000, 3, 10, 4, 3, 2, 2, 0,  1},
 {1000000, 3, 8, 2, 3, 2, 2, 0,  1}
 
2.In Function void can_flexcan_init(void)
 
  unsigned long *mbuf0 = (unsigned long *) (0x00000000+0x0220);
 
  In above line how *mbuf0 is pointing to 0x00000220 address ? Is there any requirement or from where 0x0220 value got ?
 
3.*mbuf0 = (unsigned long) can_Rx;
 
    In above line Can_Rx is a interrupt which returns nothing i.e void then why is type casted to (unsigned long) can we call the interrupt like that ? can you please explain ?
 
4.MCF5282_INTC1_ICR08 = MCF5282_INTC_ICR_IL(5) | MCF5282_INTC_ICR_IP(2); // MBUF0
 
  In the above line how the Interrupt flag is setting ? what is MCF5282_INTC_ICR_IL and MCF5282_INTC_ICR_IP stands for ? those are #defines value.
 
 can you explain the above line(point 4) please.
 
5. In one file under fat folder (FLEXCAN_test) there one line says that
set s-clock to 500kHz. i.e MCF5282_FLEXCAN_PRESDIV = 0x83 can you explain how it is set to 500kHz.I have read the bit timming reuirements but not understood properely. As per formulae to find
s-clock =  fsys/2(PRESDIV+1), As per the formulae I am not getting 500kHz.Help me in this regards.
 
Awaiitng for your positive reply.
 
Regards,
krishna
 
 
0 Kudos

453 Views
FredT
Contributor II
A CAN device cannot work alone. It have to be connect to others device. There's also a loop-back mode that will have the message sent back to the device. I don't know if it's available on your's.
0 Kudos