Hello. Thank you so much for your answer last time. I have a problem with CAN interrupt today, so I would like to ask you a question.
First of all, I wrote a code to receive RX data by sending TX data from CAN1 IF1 to CAN2 IF1. However, we found a problem where the interrupts of CAN1 continue to occur when TxIE of CAN1 IF1MCTL is disabled. Of course, we can use conditional statements to stop data transmission, but I don't understand the reason why the interruption continues even if we disable TxIE.
So I asked you this question just in case how to solve the interrupt problem.
Thank you for reading it. Please give me a lot of advice and criticism.


/** @file sys_main.c
* @brief Application main file
* @date 11-Dec-2018
* @version 04.07.01
*
* This file contains an empty main function,
* which can be used for the application.
*/
/*
* Copyright (C) 2009-2018 Texas Instruments Incorporated - www.ti.com
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/* USER CODE BEGIN (0) */
/* USER CODE END */
/* Include Files */
#include "sys_common.h"
/* USER CODE BEGIN (1) */
#include "can.h"
#include "sys_core.h"
/* USER CODE END */
/** @fn void main(void)
* @brief Application main function
* @note This function is empty by default.
*
* This function is called after startup.
* The user can use this function to implement the application.
*/
/* USER CODE BEGIN (2) */
#define Total_Size 24
#define canByte 8
uint8 TX_DATA[Total_Size] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23};
uint8 RX_DATA[Total_Size] = {0};
uint8 *tx_ptr = &TX_DATA[0];
uint8 *rx_ptr = &RX_DATA[0];
uint32 Frame_Size = 0;
uint8 fGo = 0;
uint32 cFrame = 0;
void canMessageNotificantion(canBASE_t *node, uint32 channel);
void canTXCommunication(canBASE_t *node, uint32 messageBox, uint8 *data, uint32 Frame_Size);
void canRXCommunication(canBASE_t *node, uint32 messageBox, uint8 *data);
/* USER CODE END */
int main(void)
{
/* USER CODE BEGIN (3) */
canInit();
_enable_interrupt_();
Frame_Size = Total_Size/canByte;
while(1)
{
if(fGo == 1)
{
canTXCommunication(canREG1, canMESSAGE_BOX1, tx_ptr, Frame_Size);
fGo = 0;
}
}
/* USER CODE END */
}
/* USER CODE BEGIN (4) */
void canTXCommunication(canBASE_t *node, uint32 messageBox, uint8 *data, uint32 Frame_Size)
{
int i = 0;
while((node->IF1STAT & 0x80U) == 0x80U)
{
}
cFrame++;
if(cFrame >= Frame_Size)
{
node -> IF1MCTL &= 0xFFFFF7FF;
cFrame = 0;
}
node -> IF1CMD = 0x87;
for(i=0; i<8; i++)
{
node -> IF1DATx[i] = *data;
data++;
}
node -> IF1NO = (uint8) messageBox;
}
void canRXCommunication(canBASE_t *node, uint32 messageBox, uint8 *data)
{
int i = 0;
uint8 *pData = data;
while((node->IF1STAT & 0x80U) == 0x80U)
{
}
node -> IF1CMD = 0x17;
node -> IF1NO = (uint8) messageBox;
for(i=0; i<8; i++)
{
*pData = node -> IF1DATx[i];
pData++;
}
}
void canMessageNotification(canBASE_t *node, uint32 messageBox)
{
if(node == canREG1)
{
//if((node -> IF1MCTL & 0x800U) == 0x800U)
// {
tx_ptr += 8;
canTXCommunication(canREG1, canMESSAGE_BOX1, tx_ptr, Frame_Size);
// }
}
else if(node == canREG2)
{
canRXCommunication(canREG2, canMESSAGE_BOX1, rx_ptr);
rx_ptr += 8;
}
else
{
while(1);
}
}
/* USER CODE END */
