Hello,
I got a problems with using mask on CAN messages on TMS570LS3137. Any mask that I'm trying to apply pass any messages that I'm sent. CAN interface configured by HalCoGen 3.03.01. using of CAN mask is necessary in my project.
Here are codes of using and initialization:
void canTRFunc()
{
while(1)
{
canTransmit(canREG1, canMESSAGE_BOX1, canTX);
while(!canIsRxMessageArrived(canREG2, canMESSAGE_BOX1));
canGetData(canREG2, canMESSAGE_BOX1, canRX);
sciDisplayText(scilinREG, "RECEIVED: ", sizeof("RECEIVED: "));
sciDisplayText(scilinREG, canRX, sizeof(canRX));
sciDisplayText(scilinREG, txtCRLF, sizeof(txtCRLF));
}
}
void canInit(void)
{
/* USER CODE BEGIN (3) */
/* USER CODE END */
/** @b Initialize @b CAN1: */
/** - Setup control register
* - Disable automatic wakeup on bus activity
* - Local power down mode disabled
* - Disable DMA request lines
* - Enable global Interrupt Line 0 and 1
* - Disable debug mode
* - Release from software reset
* - Enable/Disable parity or ECC
* - Enable/Disable auto bus on timer
* - Setup message completion before entering debug state
* - Setup normal operation mode
* - Request write access to the configuration registers
* - Setup automatic retransmission of messages
* - Disable error interrupts
* - Disable status interrupts
* - Enter initialization mode
*/
canREG1->CTL = 0x00000000U
| 0x00000000U
| 0x00000005U
| 0x00020043U;
/** - Clear all pending error flags and reset current status */
canREG1->ES = canREG1->ES;
/** - Assign interrupt level for messages */
canREG1->INTMUXx[0U] = 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U;
canREG1->INTMUXx[1U] = 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U;
/** - Setup auto bus on timer period */
canREG1->ABOTR = 0U;
/** - Initialize message 1
* - Wait until IF1 is ready for use
* - Set message mask
* - Set message control word
* - Set message arbitration
* - Set IF1 control byte
* - Set IF1 message number
*/
while (canREG1->IF1STAT & 0x80);
canREG1->IF1MSK = 0xC0000000U | ((0x000007FFU & 0x1FFFFFFFU) << 0U);
canREG1->IF1ARB = 0x80000000U | 0x40000000U | 0x20000000U | ((1U & 0x1FFFFFFFU) << 0U);
canREG1->IF1MCTL = 0x00001080U | 0x00000C00U | 1U;
canREG1->IF1CMD = 0xF8;
canREG1->IF1NO = 1;
/** - Setup IF1 for data transmission
* - Wait until IF1 is ready for use
* - Set IF1 control byte
*/
while (canREG1->IF1STAT & 0x80);
canREG1->IF1CMD = 0x87;
/** - Setup IF2 for reading data
* - Wait until IF1 is ready for use
* - Set IF1 control byte
*/
while (canREG1->IF2STAT & 0x80);
canREG1->IF2CMD = 0x17;
/** - Setup bit timing
* - Setup baud rate prescaler extension
* - Setup TSeg2
* - Setup TSeg1
* - Setup sample jump width
* - Setup baud rate prescaler
*/
canREG1->BTR = (0U << 16U) |
((2U - 1U) << 12U) |
(((3U + 2U) - 1U) << 8U) |
((2U - 1U) << 6U) |
19U;
/** - CAN1 Port output values */
canREG1->TIOC = (1 << 18 )
| (0 << 17 )
| (1 << 3 )
| (0 << 2 )
| (0 << 1 )
| (0 );
canREG1->RIOC = (1 << 18 )
| (0 << 17 )
| (1 << 3 )
| (0 << 2 )
| (0 <<1 )
| (0 );
/** - Leave configuration and initialization mode */
canREG1->CTL &= ~0x00000041U;
/** @b Initialize @b CAN2: */
/** - Setup control register
* - Disable automatic wakeup on bus activity
* - Local power down mode disabled
* - Disable DMA request lines
* - Enable global Interrupt Line 0 and 1
* - Disable debug mode
* - Release from software reset
* - Enable/Disable parity or ECC
* - Enable/Disable auto bus on timer
* - Setup message completion before entering debug state
* - Setup normal operation mode
* - Request write access to the configuration registers
* - Setup automatic retransmission of messages
* - Disable error interrupts
* - Disable status interrupts
* - Enter initialization mode
*/
canREG2->CTL = 0x00000000U
| 0x00000000U
| 0x00000005U
| 0x00020043U;
/** - Clear all pending error flags and reset current status */
canREG2->ES = canREG2->ES;
/** - Assign interrupt level for messages */
canREG2->INTMUXx[0U] = 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U;
canREG2->INTMUXx[1U] = 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U;
/** - Setup auto bus on timer period */
canREG2->ABOTR = 0U;
/** - Initialize message 1
* - Wait until IF1 is ready for use
* - Set message mask
* - Set message control word
* - Set message arbitration
* - Set IF1 control byte
* - Set IF1 message number
*/
while (canREG2->IF1STAT & 0x80);
canREG2->IF1MSK = 0xC0000000U | ((0x00000000U & 0x1FFFFFFFU) << 0U);
canREG2->IF1ARB = 0x80000000U | 0x40000000U | 0x00000000U | ((1U & 0x1FFFFFFFU) << 0U);
canREG2->IF1MCTL = 0x00001080U | 0x00000400U | 1U;
canREG2->IF1CMD = 0xF8;
canREG2->IF1NO = 1;
/** - Setup IF1 for data transmission
* - Wait until IF1 is ready for use
* - Set IF1 control byte
*/
while (canREG2->IF1STAT & 0x80);
canREG2->IF1CMD = 0x87;
/** - Setup IF2 for reading data
* - Wait until IF1 is ready for use
* - Set IF1 control byte
*/
while (canREG2->IF2STAT & 0x80);
canREG2->IF2CMD = 0x17;
/** - Setup bit timing
* - Setup baud rate prescaler extension
* - Setup TSeg2
* - Setup TSeg1
* - Setup sample jump width
* - Setup baud rate prescaler
*/
canREG2->BTR = (0U << 16U) |
((2U - 1U) << 12U) |
(((3U + 2U) - 1U) << 8U) |
((2U - 1U) << 6U) |
19U;
/** - CAN2 Port output values */
canREG2->TIOC = (1 << 18 )
| (0 << 17 )
| (1 << 3 )
| (0 << 2 )
| (0 << 1 )
| (0 );
canREG2->RIOC = (1 << 18 )
| (0 << 17 )
| (1 << 3 )
| (0 << 2 )
| (0 <<1 )
| (0 );
/** - Leave configuration and initialization mode */
canREG2->CTL &= ~0x00000041U;
/** @note This function has to be called before the driver can be used.\n
* This function has to be executed in privileged mode.\n
*/
/* USER CODE BEGIN (4) */
/* USER CODE END */
}
Regards, Alexandr.