实验中发现寄存器C1BUFPNT1在接收到报文后里面的值会被修改,按照以下范例,该值为初始化设定后不被修改。 求助各路大神,跪谢!
/******************************************************************************
* Function: void Ecan1WriteRxAcptFilter(int16_t n, int32_t identifier,
* uint16_t exide,uint16_t bufPnt,uint16_t maskSel)
*
* PreCondition: None
*
* Input: n-> Filter number [0-15]
* identifier-> Bit ordering is given below
* Filter Identifier (29-bits) :
* 0b000f ffff ffff ffff ffff ffff ffff ffff
* |____________|_____________________|
* SID10:0 EID17:0
*
* Filter Identifier (11-bits) :
* 0b0000 0000 0000 0000 0000 0fff ffff ffff
* |___________|
* SID10:
* exide -> "0" for standard identifier
* "1" for Extended identifier
* bufPnt -> Message buffer to store filtered message [0-15]
* maskSel -> Optinal Masking of identifier bits [0-3]
*
* Output: None
*
* Side Effects: None
*
* Overview: Configures Acceptance filter "n" for ECAN1.
*****************************************************************************/
void Ecan1WriteRxAcptFilter( int16_t n, int32_t identifier, uint16_t exide, uint16_t bufPnt, uint16_t maskSel )
{
uint32_t sid10_0 = 0;
uint32_t eid15_0 = 0;
uint32_t eid17_16 = 0;
uint16_t *sidRegAddr;
uint16_t *bufPntRegAddr;
uint16_t *maskSelRegAddr;
uint16_t *fltEnRegAddr;
C1CTRL1bits.WIN = 1;
// Obtain the Address of CiRXFnSID, CiBUFPNTn, CiFMSKSELn and CiFEN register for a given filter number "n"
sidRegAddr = ( uint16_t * ) ( &C1RXF0SID + (n << 1) );
bufPntRegAddr = ( uint16_t * ) ( &C1BUFPNT1 + (n >> 2) );
maskSelRegAddr = ( uint16_t * ) ( &C1FMSKSEL1 + (n >> 3) );
fltEnRegAddr = ( uint16_t * ) ( &C1FEN1 );
|