Hello,
I have troubles trying to make work the CAN interruption.
Interruptions work fine if I configure either standard or extended CAN ID through the HAL. However, if I want to change from standard to extended CAN or from extended to standard through code, the CAN interrupt stops working. I have made two functions that help me to change from one format to another by receiving a command by SCI (UART).
With the logic analyzer I have verified that the frames are sent in the corresponding formats, but the interrupt is not triggered.
I attach below the code of both functions.
//Set standard ID for some CAN interface void standardId(canBASE_t *canREG) { /** - 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 */ /*SAFETYMCUSW 28 D MR:NA <APPROVED> "Potentially infinite loop found - Hardware Status check for execution sequence" */ while ((canREG->IF1STAT & 0x80U) ==0x80U) { } /* Wait */ canREG->IF1MSK = 0xC0000000U | (uint32)((uint32)((uint32)0x00000000U & (uint32)0x000007FFU) << (uint32)18U); canREG->IF1ARB = (uint32)0x80000000U | (uint32)0x00000000U | (uint32)0x20000000U | (uint32)((uint32)((uint32)1U & (uint32)0x000007FFU) << (uint32)18U); canREG->IF1MCTL = 0x00001000U | (uint32)0x00000000U | (uint32)0x00000000U | (uint32)0x00000000U | (uint32)8U; canREG->IF1CMD = (uint8) 0xF8U; canREG->IF1NO = 1U; } //Set extended ID for some CAN interface void extendedId(canBASE_t *canREG) { /** - 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 */ canREG->CTL = (uint32)0x00000000U | (uint32)0x00000020U | (uint32)((uint32)0x00000005U << 10U) | 0x00020043U; /** - 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 */ /*SAFETYMCUSW 28 D MR:NA <APPROVED> "Potentially infinite loop found - Hardware Status check for execution sequence" */ while ((canREG->IF1STAT & 0x80U) ==0x80U) { } /* Wait */ canREG->IF1MSK = 0xC0000000U | (uint32)((uint32)((uint32)0x00000000U & (uint32)0x1FFFFFFFU) << (uint32)0U); canREG->IF1ARB = (uint32)0x80000000U | (uint32)0x40000000U | (uint32)0x20000000U | (uint32)((uint32)((uint32)1U & (uint32)0x1FFFFFFFU) << (uint32)0U); canREG->IF1MCTL = 0x00001000U | (uint32)0x00000000U | (uint32)0x00000000U | (uint32)0x00000000U | (uint32)8U; canREG->IF1CMD = (uint8) 0xF8U; canREG->IF1NO = 1U; /** - Leave configuration and initialization mode */ canREG->CTL &= ~(uint32)(0x00000041U); }
Thanks a lot and regards,
Leandro