- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The Port-14.1 is set as CAN reception port.
I want to detect CAN reception using the WCAN interrupt on the SCR side, but it doesn't work.
The WCAN settings for the SCR are as follows.
What is the problem?
The CAN ID being sent is 10200101h.
Communication speed is 250k.
/* WCAN Start */
SCR_SCU_PAGE = 2;
SCR_MODPISEL0 = 0x50; // WCANRXDF
SCR_WCAN_PAGE = 0;
SCR_WCAN_CFG = SCR_WCAN_CFG | 0x01; // WCAN_EN = 1
SCR_WCAN_CFG = SCR_WCAN_CFG | 0x08; // CCE = 1
SCR_IEN1 = SCR_IEN1 | 0x01;/* Enable WCAN filter interrupts */
//configure baud rate
SCR_WCAN_PAGE = 1;
SCR_WCAN_BTL1_CTRL = 0x64;
SCR_WCAN_BTL2_CTRL = SCR_WCAN_BTL2_CTRL & 0x3F;
SCR_WCAN_BTL2_CTRL = SCR_WCAN_BTL2_CTRL | 0xC0;
// CDR setting
SCR_WCAN_PAGE = 0;
SCR_WCAN_CDR_CTRL = SCR_WCAN_CDR_CTRL & 0xFE;
SCR_WCAN_CDR_CTRL = SCR_WCAN_CDR_CTRL | 0x01; //Enable CDR
SCR_WCAN_PAGE = 0;
SCR_WCAN_CFG = SCR_WCAN_CFG & 0xF7; // CCE = 0
SCR_WCAN_CFG = SCR_WCAN_CFG & 0xFB; // SELWK_EN = 0
SCR_WCAN_INTMRSLT = 0x0F;
SCR_WCAN_PAGE = 0;
SCR_WCAN_CFG = SCR_WCAN_CFG | 0x04; // SELWK_EN = 1
// SCR_WCAN_PAGE = 1;
while( !( SCR_WCAN_INTESTAT0 & 0x01) )
{
}
SCR_WCAN_PAGE = 1;
SCR_WCAN_DLC_CTRL = 0x08; //DLC = 8
SCR_WCAN_PAGE = 2;
SCR_WCAN_ID0_CTRL = 0xFF;
SCR_WCAN_ID1_CTRL = 0xFF;
SCR_WCAN_ID2_CTRL = 0xFF;
SCR_WCAN_ID3_CTRL = 0x10;
SCR_WCAN_MASK_ID0_CTRL = 0x00;
SCR_WCAN_MASK_ID1_CTRL = 0x00;
SCR_WCAN_MASK_ID2_CTRL = 0x00;
SCR_WCAN_MASK_ID3_CTRL = 0x00;
SCR_WCAN_PAGE = 0;
SCR_WCAN_CFG = SCR_WCAN_CFG & 0xFB;
SCR_WCAN_CFG = SCR_WCAN_CFG | 0x04; //SELWK_EN = 1b
SCR_WCAN_INTMRSLT = 0x0C; //Wake-Up CAN Interrupt Mask Register
// SCR_WCAN_PAGE = 1;
while( ( SCR_WCAN_INTESTAT0 & 0x01 ) != 1 )
{
}
/* WCAN End */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Could you please check if this code is useful?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
SWKSET = 1 only when:
• WCAN_CFG.WCAN_EN = 1b
• WCAN_CFG.CCE = 0b -->
• WCAN_INTESTAT0.SWACK = 1b
• WCAN_INTESTAT0.MODE = 0b
This bit getting set in the code WCAN_CFG.WCAN_EN.
1. Reset the bit WCAN_CFG.SELWK_EN
2. Wait until WCAN_INTESTAT0.SWACK =0
3. //WUF register to be configured
4. Set WCAN_CFG.SELWK_EN = 1b
5. Wait until WCAN_INTESTAT0.SWACK = 1b
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry for my late reply.
I will attach my source code as a pdf file.
The board I'm using is a P33.12 CAN receiver, so I changed the code a bit.
CAN can send and receive with no problem in Tricore project.
SCR failed to detect CAN reception.
I am interrupting with the "Wcan_Int" function, but there is no response.
The transmitted CAN ID is 0x200, is this correct?
Added timer interrupt code to check if interrupts work.
Timer interrupt worked fine.
What's wrong with this WCAN configuration?