FlexCan on MQX 3.5.1

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

FlexCan on MQX 3.5.1

1,131 Views
elel
Contributor III

Hi everybody, I've a problem with the flexcan driver in mqx3.5.1.

 

I use an MCF52259 on my own designed board, and the codewarrior V7.1.2.

 

Now I've to develop a can bus communication, so I'm trying to use the flexcan driver, but I get some errors.

 

I've copied the flexcan example from the folder "mqx/examples/can/flexcan" and I've compiled it for my board, the code is the same of the example the only thing changing is the rom start address, because I've develop a bootloader for my board.

Another difference between my code and the example is that I'm trying to communicate at 1Mbit/s, and that I've changed the prescaler,PSEG1,PSEG2,and PROPSEG initializations because the frequency of my system in 48Mhz.

 

 

Theese are my settings:

                 can_reg_ptr->CANCTRL |= (0 | FLEXCAN_CANCTRL_PROPSEG(6) | FLEXCAN_CANCTRL_RJW(1)
                                             | FLEXCAN_CANCTRL_PSEG1(7) | FLEXCAN_CANCTRL_PSEG2(7)
                                             | FLEXCAN_CANCTRL_PRESDIV(0) | FLEXCAN_CANCTRL_SAMP);

 

Are they correct?

 

First I've tryed if I'm able to send. So I've commented out the creation of the RX_task and I've used only the TX_task; all the functions calls return no error, and all the registers seems at the correct values, but I don't see nothing out from the pins.

 

 

A strange thing I've noticed is that the "end of trasmission ISR" is never generated, instead is generated at each transmission an error ISR that report strange error, like ACK error or bit stuffing error... it's possible that theese errors are generated by the absence of other nodes on the net?

 

Thanks in advance.

 

Best regards.

Stefano

0 Kudos
2 Replies

404 Views
PetrM
Senior Contributor I

I'd say you should use FLEXCAN_CANCTRL_PRESDIV(1) to divide the system clock by 2 and then split into 24 time quanta to get 1 MHz. That could be the source of the bit errors you get.

 

PetrM

0 Kudos

404 Views
Awera
Contributor III

Hi,

 

If you don't have any node connected, you will always have a ACK error cause there is no node to confirm your transmission (the other node reports a correct transmission by sending a dominant bit during ACK slot, on a CAN Frame).

 

If you want to test CAN transmission, you can put it on LOOPBACK mode (CANCTRL register). All what you send, you will receive.

0 Kudos