Hello,
I'm developing on S32R274,when I try to configure CAN0' Loop-back mode ,I set a breakpoint in the interupt handle function but it dosn't hit.
Here is my init code:
void FlexCAN_0_Init(void)
{
int i = 0;
//configure I/O
SIUL2.MSCR[16].B.SSS = 1; /* CAN0_TXD L15: Source signal is CAN0_TX */
SIUL2.MSCR[16].B.OBE = 1; /* CAN0_TXD L15: Output Buffer Enable */
SIUL2.MSCR[16].B.SRC = 3; /* CAN0_TXD L15: Maximum slew rate */
SIUL2.MSCR[17].B.IBE = 1; /*CAN0_RXD M17: Enable pad for input - CAN0_RXD */
SIUL2.IMCR[0].B.SSS = 0; /* CAN_0_RXD: connected to pad M17 */
/*Module enable*/
CAN_0.MCR.B.MDIS = 0;//frank: 0 is enable
/*Source clk is oscillator clock (40MHz)*/
CAN_0.CTRL1.B.CLKSRC = 0;
/*Error correction configuration register enable*/
CAN_0.CTRL2.B.ECRWRE = 1;
/*Enable unrestricted write access to FlexCAN memory*/
CAN_0.CTRL2.B.WRMFRZ = 1;
/*Error configuration register write enable*/
CAN_0.MECR.B.ECRWRDIS = 0;
/*Disable memory error correction*/
CAN_0.MECR.B.ECCDIS = 1;
/*Keep normal operation*/
CAN_0.MECR.B.NCEFAFRZ = 0;
/*Error configuration register write disable*/
CAN_0.MECR.B.ECRWRDIS = 1;
/*Disable unrestricted write access to FlexCAN memory*/
CAN_0.CTRL2.B.WRMFRZ = 0;
/*Error correction configuration register disable*/
CAN_0.CTRL2.B.ECRWRE = 0;
/*CAN bit timing - 40MHz oscillator, 100kbps bitrate,*/
CAN_0.CTRL1.B.PRESDIV = 39;//frank: this field can be written only in Freeze mode
CAN_0.CTRL1.B.RJW = 3;//frank: this value is 0-3
CAN_0.CTRL1.B.PSEG1 = 3;//frank: this field can be written only in Freeze mode
CAN_0.CTRL1.B.PSEG2 = 3;//frank: this field can be written only in Freeze mode
CAN_0.CTRL1.B.PROPSEG = 0;
CAN_0.CTRL1.B.LPB=1;//frank:enable loop-back mode
/*Clear all RX individual Mask Registers The corresponding bit in the
* filter is "don't care."*/
for(i = 0; i < 64; i++)//frank:change 64 to 96 CAN0 support CAN-FD(96)
{
CAN_0.RXIMR[i].R = 0x00000000;
}
/*Set all message buffers RX inactive*/
for(i = 0; i <64; i++)
{
CAN_0.MB[i].CS.R = 0x0000;
}
/*No freeze mode request*/
CAN_0.MCR.B.HALT = 0;
CAN_0.IMASK1.R=0x0F;//frank: add
INTC.PSR[522].B.PRC_SELN0=1;//frank: sent interupt to core0
INTC.PSR[522].B.PRIN=2;//frank: set the interupt priority
//configure RX buffer,
CAN_0.MB[0].CS.B.CODE = 0x0; //MB inactive
CAN_0.MB[0].CS.B.IDE = 1;
CAN_0.MB[0].ID.R = 0; //set standard ID
CAN_0.MB[0].DATA.W[1] = 0x00000000; //data1 set (optional)
CAN_0.MB[0].DATA.W[0] = 0x00000000; //data0 set (optional)
CAN_0.MB[0].CS.B.CODE = 0x4; //MB empty - ready for receive
CAN_0.MB[1].CS.B.CODE = 0x0; //MB inactive
CAN_0.MB[1].CS.B.IDE = 1;
CAN_0.MB[1].ID.R = 100; //set standard ID
CAN_0.MB[1].DATA.W[1] = 0x00000000; //data1 set (optional)
CAN_0.MB[1].DATA.W[0] = 0x00000000; //data0 set (optional)
CAN_0.MB[1].CS.B.CODE = 0x4; //MB empty - ready for receive
CAN_0.MB[2].CS.B.CODE = 0x0; //MB inactive
CAN_0.MB[2].CS.B.IDE = 1;
CAN_0.MB[2].ID.R = 1000; //set standard ID
CAN_0.MB[2].DATA.W[1] = 0x00000000; //data1 set (optional)
CAN_0.MB[2].DATA.W[0] = 0x00000000; //data0 set (optional)
CAN_0.MB[2].CS.B.CODE = 0x4; //MB empty - ready for receive
}
Also I had add ISR function into the IntcIsrVectorTable
Who can give me a sample for CAN0 Loop-back mode?
Thank you for your support
Frank.wei
The register of CAN0.MCR.B.NOTRDY and CAN0.MCR.B.FRZ is always keep 1 ,even thougth the CAN0.MCR.B.HAL was set to 0