取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
xumoxiao
Explorer
Explorer
262 次查看
注册日期: ‎12-12-2018

xcanfd v2.0 IP 在sdk中运行polling example 无法进入 Normal Mode

大佬们帮忙看看啥问题。
Vivado 18.3 ,有canfd 的license

正常跑 example 没有问题。

但是需要实际进行can数据的收发,需要进入Normal Mode。

int XCanFdPolledExample(u16 DeviceId)
{
	int Status;
	XCanFd *CanFdInstPtr = &CanFd;
	XCanFd_Config *ConfigPtr;
	u32 IdValue;
	u32 BuffNr;
	u8 RxBuffers;

	/* Initialize the Can device */
	ConfigPtr = XCanFd_LookupConfig(DeviceId);
	if (CanFdInstPtr == NULL) {
		return XST_FAILURE;
	}
	Status = XCanFd_CfgInitialize(CanFdInstPtr,
					ConfigPtr,
					ConfigPtr->BaseAddress);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	/*
	 * Run self-test on the device, which verifies basic sanity of the
	 * device and the driver.
	 */
	Status = XCanFd_SelfTest(CanFdInstPtr);
	if (Status != XST_SUCCESS) {
		return Status;
	}
	/*
	 * Enter Configuration Mode so we can setup Baud Rate Prescaler
	 * Register (BRPR) and Bit Timing Register (BTR)
	 */
	XCanFd_EnterMode(CanFdInstPtr, XCANFD_MODE_CONFIG);
	while (XCanFd_GetMode(CanFdInstPtr) != XCANFD_MODE_CONFIG);

	/*
	 * Configure the Baud Rate Prescalar in
	 * Arbitration Phase
	 */
	XCanFd_SetBaudRatePrescaler(CanFdInstPtr, TEST_BRPR_BAUD_PRESCALAR);

	/*
	 * Configure the Bit Timing Values in
	 * Arbitration Phase.
	 */
	XCanFd_SetBitTiming(CanFdInstPtr, TEST_BTR_SYNCJUMPWIDTH,
		TEST_BTR_SECOND_TIMESEGMENT,TEST_BTR_FIRST_TIMESEGMENT);

	 /* Configure the Baud Rate Prescalar in Data Phase */
	XCanFd_SetFBaudRatePrescaler(CanFdInstPtr, TEST_FBRPR_BAUD_PRESCALAR);

	/* Configure the Bit Timing Values in Data Phase */
	XCanFd_SetFBitTiming(CanFdInstPtr,TEST_FBTR_SYNCJUMPWIDTH,
		TEST_FBTR_SECOND_TIMESEGMENT,TEST_FBTR_FIRST_TIMESEGMENT);

	/*
	 * Disable the Global BRS Disable so that
	 * at the time of sending the can frame
	 * we will choose whether we need Bit
	 * Rate Switch or not.
	 */
	XCanFd_SetBitRateSwitch_DisableNominal(CanFdInstPtr);
	/*
	 * Check for the design
	 * 0 - Sequential Mode
	 * 1 - MailBox Mode.
	 */
	if (XCANFD_GET_RX_MODE(CanFdInstPtr) == 0) {
		XCanFd_AcceptFilterDisable(CanFdInstPtr,
			XCANFD_AFR_UAF_ALL_MASK);
		XCanFd_AcceptFilterEnable(CanFdInstPtr,
			XCANFD_AFR_UAF_ALL_MASK);
	}
	else {
		RxBuffers = XCanFd_Get_RxBuffers(CanFdInstPtr);
		IdValue = XCanFd_CreateIdValue(TEST_MESSAGE_ID, 0, 0, 0, 0);
		for (BuffNr = 0;BuffNr < RxBuffers;BuffNr++) {
			XCanFd_RxBuff_MailBox_DeActive(CanFdInstPtr,BuffNr);
			XCanFd_Set_MailBox_IdMask(CanFdInstPtr,BuffNr,
				TEST_MAILBOX_MASK,IdValue);
			XCanFd_RxBuff_MailBox_Active(CanFdInstPtr,BuffNr);
		}
	}

	/* Configure CAN Device to enter to Loop Back Mode */
	//XCanFd_EnterMode(CanFdInstPtr, XCANFD_MODE_LOOPBACK);
	//while (XCanFd_GetMode(CanFdInstPtr) != XCANFD_MODE_LOOPBACK);

	XCanFd_EnterMode(CanFdInstPtr, XCANFD_MODE_NORMAL);
	while (XCanFd_GetMode(CanFdInstPtr) != XCANFD_MODE_NORMAL);

	/* Send Frame */
	Status = SendFrame(CanFdInstPtr);
	if (Status != XST_SUCCESS) {
		return Status;
	}

	/* Receive The Frame */
	Status = RecvFrame(CanFdInstPtr);
	return Status;

}

此时,会移植停留在 while (XCanFd_GetMode(CanFdInstPtr) != XCANFD_MODE_NORMAL); 语句当中,因为我配置的Normal Mode 没有生效。

NormalMode.png 

可以看到,0x18 依然停留在 Config Mode.

请问要如何进入Normal mode,正常收发 Can数据?

标记 (3)
0 项奖励
回复
2 回复数
xumoxiao
Explorer
Explorer
234 次查看
注册日期: ‎12-12-2018

为什么 example 里面只有loopback?如何正常收发呀?
0 项奖励
回复
xumoxiao
Explorer
Explorer
227 次查看
注册日期: ‎12-12-2018

顶一下。
0 项奖励
回复