| 数据搜索系统,热门电子元器件搜索 |
|
AN2341 数据表(PDF) 9 Page - STMicroelectronics |
|
|
|||||||||||||||||||||||||||||
AN2341 数据表(HTML) 9 Page - STMicroelectronics |
|
9 / 26 page ![]() AN2341 Programming through CAN hardware features 9/26 3 Programming through CAN hardware features Programming the CAN interrupt drivers through CAN hardware features uses bits RXIE and TXIE in the message control register of each message object. Whenever a message is transmitted or received by a message object, the corresponding interrupt is serviced according to its priority (based on the value of IntId). This method uses the hardwired priority scheme of the CAN module and requires minimum CPU overhead. This section provides a sample program for programming through CAN hardware features. Hints: ● If the Status Change Interrupt is enabled, the CPU is interrupted every time a message is acknowledged on the CAN bus. Disable the Status Change Interrupt! ● RXOK is cleared by the Status Change Interrupt routine. Therefore, do not use RXOK to identify the cause of interrupts. ● TXOK can be used to identify the cause of an interrupt if the Status Change Interrupt is disabled and if TXOK is cleared by every interrupt routine of message objects with direction = ‘transmit’. For clarity, the example below assumes that Status Change Interrupt is enabled. ● There are two ways to use the sample program provided below: – The software interrupt driver repeats itself as long as there is an active interrupt in the CAN module. – The software driver is run once and handles only one interrupt. This allows the interrupt controller to re-arbitrate interrupts of the same priority level but not of a higher priority group. // CAN interrupt driver include <REGF2xxx.h> // standard include file for F27x/F25x #include "CCAN_drvs.h" // inc file to define bit masks and macro // see Section 6 for description. interrupt(0x4x) void CAN_IT (void) // CAN Module IR, trap number 0x40, 0x41, 0x43, // according to user choice, see Section 1.1 { XIRxCLR = 0xXX; //flag to be cleared according to user choice //see Section 1.1 unsigned char status, intid, control; while (intid=CANxIR) //reload intid with CANxIR, // continue loop if intid != 0 //‘while’can be removed to run IT driver once { status = CANxSR;// copy status + control REG to variable control = CANxCR; CANxSR=0; // clear status register switch (intid) { case 0x8000: // Status Change Interrupt if (CANxCR & SIE)// if SIE is set (status interrupts) { |
|
|
链接网址 |
| ALLDATASHEET是否为您带来帮助? [ DONATE ] |
关于 Alldatasheet | 广告服务 | 联系我们 | 隐私政策 | 数据表链接 | 链接交换 | 制造商名单 All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |