| 数据搜索系统,热门电子元器件搜索 |
|
AN2628 数据表(PDF) 13 Page - STMicroelectronics |
|
|
|||||||||||||||||||||||||||||
AN2628 数据表(HTML) 13 Page - STMicroelectronics |
|
13 / 27 page ![]() AN2628 Programming through polling 13/27 4 Programming through polling Programming the interrupt driver using polling generates an interrupt whenever a successful transmission or reception occurs. This is done by setting bit SIE of the control register. RXOK or TXOK is (or both are) set when a message object transmits or receives a message. The CAN module sets RXOK whenever a message is acknowledged on the CAN bus. Once in the interrupt routine, the CPU polls bit IntPnd of each message object. The message object polling sequence defines the message object priority, independent of the existing hardware priority scheme defined for IntId. Polling is high in the CPU overhead as the CPU is interrupted every time a message is acknowledged on the CAN bus. Therefore, programming the interrupt driver using polling is recommended for small networks only. This section provides a sample program for programming through polling. // 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) // CAN Module IR, trap number 0x40, 0x41, 0x43, void CAN_IT (void)// according to user choice see Section 1.1 { unsigned short i; unsigned char status, control; { status = CANxSR;// copy status + control REG to variable control = CANxCR; CANxSR=0; // clear status register XIRxCLR = 0xXX; //flag to be cleared according to user choice //see Section 1.1 CANxIF1CM = 0x7F; // Transfer entire message into interface CANxIF1CR = 1; // register and clear IntPnd and NewDat CANx_WAIT_FOR_IF1; if (CANxIF1MC & IF_INTPND) {.....} // procedure to handle message 1 interrupts .... CANxIF1CM = 0x7F; // Transfer entire message into inference CANxIF1CR = 32; // register and clear IntPnd and NewDat CANx_WAIT_FOR_IF1; if (CANxIF1MC & IF_INTPND) {.....} // procedure to handle message 32 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 |