I'm trying to initialize my M52235EVB FlexCan controler and I'm getting a state of the ERRSTAT register that told me the Bus is off (ERRSTAT = 0x00004036). The module is enabled, and I have set the first Message Buffer Code to 1100b with fake data to see if the Code change to 1000b, but it stays in the 1100b state.
Is there any jumper I have to modify from the board ?
I'm using an CAN-USB device as my second CAN device.
I was using the internal clock (CLK_SRC set in CANCTRL register) and I had a timing problem. The M52235EVB have a 25MHz crystal and the SYNCR MFD bits have a 0x4 value, and RFD have 0x0, so the internal clock should be 25MHz x 12 = 300 MHz, but when setting PRESDIV using 300 MHz, communication doesn't work. I've try with 300MHz/2 = 150 MHz too, cause the documentation is talking about F(sys/2), but it doesn't work either.
I actually working with EXTAL as clock source (CLK_SRC bit in CANCTRL register), and set PRESDIV with this value and the communication is working well, so maybe my internal frequency isn't 300MHz or 150MHz.
Alban, you're talking using 2 CAN modules of the same micro. Are you talking about setting the RX buffers to different ID, or there is multiple CAN controler on the micro ?
Be sure the core frequency doen't go over the max spec of 60MHz. This is the output frequency from the PLL. The system frequency, which many of the peripheral modules run off, is half the core frequency. We recommend that you set the CCHR (pll pre-divider), then set the RFD to your desired RFD plus 1, set MFD, then put RFD where you want it. This will ensure that the core frequency doesn't exceed its maximum while the PLL is being set up.
Now I'm trying to set a interrupt when a message is received, but it isn't clear where to set it. I've set the IMASK and IFLAG register so interrupt will be called, but where am I suppose to indicate the adress of the function I was to be call when a new message is received.
I've look in Chapter 15 Interrupt Controler Module of the manual, and I read about the exception vector table that containt the adress, but I didn't saw something about where the Message Buffer is in the table, and where is locate the table.
I don't know your product, but CAN. You need another node on the network to acknowledge reception of the message you sent. Otherwise your node will flag an error each time a message is not acknowledged. 8 by 8 the counter will increase. It will go from Error Active to Error Passive and end in Bus Off mode.
You need another node with the same timing configuration for them to talk to each other and then the Error Counter will stay at 0 and traffic work.
Thank you Alban. I wasn't understanding the loop back mode.
Using LPB in CANCTRL for testing is a good idea finaly...
To the others beginners like me, the SYNCA and SYNCB pins must be set to CANTX and CANRX. I had to initialize all the Message Buffer cause the MAXMB in CANMCR is by default at 16.
Now I'm using the loop-back mode and the ERRCNT stay at zero. I'm filling a Message Buffer configure in Tx with data and set the Code field at 0xC to send it and the Code field change to 0x8, and the TimeStamp filed by CPU, so the transmission is Ok. One of my Message Buffer is set to the ID of my transmission, so it receive the message and change the code from 0x4 to 0x2.