This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Replies: 13
Views: 443
Part Number: IWR1642BOOST
mmWave SDK 01.02.00.05
IWR1642BOOST
Silicon revision ES1.0
Code Composer Studio Version: 8.1.0.00011
Hello,
I am attempting to add sending data over CAN to a program for the IWR1642BOOST.
I have added and removed resistors are instructed in the user guide.
My code to implement the CAN is largely lifted from the various example programs so DCANAppCalcBitTimeParams() is just taken from the can driver unit test program.
void Can_Initialize(void) { CAN_MsgObjHandle rxMsgObjHandle; int32_t retVal = 0; int32_t errCode = 0; CAN_DCANMsgObjectStats msgObjStats; CAN_OptionTLV optionTLV; CAN_DCANErrorCounter errCounter; /* Setup the PINMUX to bring out the XWR16xx CAN pins */ Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINC13_PADAG, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL); Pinmux_Set_FuncSel(SOC_XWR16XX_PINC13_PADAG, SOC_XWR16XX_PINC13_PADAG_CAN_TX); Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINE13_PADAF, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL); Pinmux_Set_FuncSel(SOC_XWR16XX_PINE13_PADAF, SOC_XWR16XX_PINE13_PADAF_CAN_RX); /* Configure the divide value for DCAN source clock */ SOC_setPeripheralClock(gMmwMssMCB.socHandle, SOC_MODULE_DCAN, SOC_CLKSOURCE_VCLK, 9U, &errCode); /* Initialize peripheral memory */ SOC_initPeripheralRam(gMmwMssMCB.socHandle, SOC_MODULE_DCAN, &errCode); /* Initialize the DCAN parameters that need to be specified by the application */ DCANAppInitParams(&appDcanCfgParams, &appDcanTxCfgParams, &appDcanRxCfgParams); gMmwMssMCB.canHandle = CAN_init(&appDcanCfgParams, &errCode); if (gMmwMssMCB.canHandle == NULL) { System_printf( "Error: CAN Module Initialization failed [Error code %d]\n", errCode); //return -1; } retVal = DCANAppCalcBitTimeParams(20000000U / 1000000, 1000000U / 1000, 1000000U, 700U, &appDcanBitTimeParams); /* Configure the CAN driver */ retVal = CAN_configBitTime(gMmwMssMCB.canHandle, &appDcanBitTimeParams, &errCode); if (retVal < 0) { System_printf( "Error: CAN Module configure bit time failed [Error code %d]\n", errCode); //return -1; } /* Setup the transmit message object */ gMmwMssMCB.txMsgObjHandle = CAN_createMsgObject(gMmwMssMCB.canHandle, 1, &appDcanTxCfgParams, &errCode); if (gMmwMssMCB.txMsgObjHandle == NULL) { System_printf( "Error: CAN create Tx message object failed [Error code %d]\n", errCode); //return -1; } /* Setup the receive message object */ rxMsgObjHandle = CAN_createMsgObject(gMmwMssMCB.canHandle, 2, &appDcanRxCfgParams, &errCode); if (rxMsgObjHandle == NULL) { System_printf( "Error: CAN create Rx message object failed [Error code %d]\n", errCode); //return -1; } }
and it is using these parameters
static void DCANAppInitParams(CAN_DCANCfgParams* dcanCfgParams, CAN_DCANMsgObjCfgParams* dcanTxCfgParams, CAN_DCANMsgObjCfgParams* dcanRxCfgParams) { /*Intialize DCAN Config Params*/ dcanCfgParams->parityEnable = 0; dcanCfgParams->intrLine0Enable = 1; dcanCfgParams->intrLine1Enable = 1; dcanCfgParams->testModeEnable = 0; dcanCfgParams->eccModeEnable = 0; dcanCfgParams->stsChangeIntrEnable = 0; dcanCfgParams->autoRetransmitDisable = 1; dcanCfgParams->autoBusOnEnable = 0; dcanCfgParams->errIntrEnable = 1; dcanCfgParams->autoBusOnTimerVal = 0; dcanCfgParams->if1DmaEnable = 0; dcanCfgParams->if2DmaEnable = 0; dcanCfgParams->if3DmaEnable = 0; dcanCfgParams->ramAccessEnable = 0; dcanCfgParams->appCallBack = DCANAppErrStatusCallback; /*Intialize DCAN tx Config Params*/ dcanTxCfgParams->xIdFlagMask = 0x1; dcanTxCfgParams->dirMask = 0x1; dcanTxCfgParams->msgIdentifierMask = 0x1FFFFFFF; dcanTxCfgParams->msgValid = 1; dcanTxCfgParams->xIdFlag = CAN_DCANXidType_11_BIT; dcanTxCfgParams->direction = CAN_Direction_TX; dcanTxCfgParams->msgIdentifier = 0xC1; //this is what needs to be determined dcanTxCfgParams->uMaskUsed = 1; dcanTxCfgParams->intEnable = 1; dcanTxCfgParams->remoteEnable = 0; dcanTxCfgParams->fifoEOBFlag = 1; dcanTxCfgParams->appCallBack = DCANAppCallback; /*Intialize DCAN Rx Config Params*/ dcanRxCfgParams->xIdFlagMask = 0x1; dcanRxCfgParams->msgIdentifierMask = 0x1FFFFFFF; dcanRxCfgParams->dirMask = 0x1; dcanRxCfgParams->msgValid = 1; dcanRxCfgParams->xIdFlag = CAN_DCANXidType_11_BIT; dcanRxCfgParams->direction = CAN_Direction_RX; dcanRxCfgParams->msgIdentifier = 0xC1; dcanRxCfgParams->uMaskUsed = 1; dcanRxCfgParams->intEnable = 1; dcanRxCfgParams->remoteEnable = 0; dcanRxCfgParams->fifoEOBFlag = 1; dcanRxCfgParams->appCallBack = DCANAppCallback; }
and the transmit is called in the mailbox task after transmiting data over UART, like so, where gMmwMssMCB.foldbackOverCan is of type CAN_DCANData
//transmit over can retVal = CAN_transmitData(( CAN_MsgObjHandle*)gMmwMssMCB.txMsgObjHandle, &gMmwMssMCB.foldbackOverCan, &errCode); if (retVal < 0) { /* Error: Unable to send the message. Setup the error code and return values */ System_printf( "Error: failed to transmit foldback over CAN [Error code %d]\n", errCode); }
The program does not give any errors but if I probe the can_l and can_h ports they both just give A 2.5v level when my program is running.
What might be causing the CAN transmit to not work? Any suggestions on how to debug this?
Thanks,
Tim
In reply to Nitin Sakhuja:
Hi Nitin,
I have now run the CAN driver unit test thanks to your help on my other post.
I have run the tests with a 120 ohm resistance between the can_l and can_h ports, probing both ports and also have probed the pin 1 of the CAN transceiver U3 but am not seeing any reading on the scope.
Running the DCAN Internal loopback test I get this on the console but only see flat voltage level on the scope.
[Cortex_R4_0] ******************************************************* CAN Unit Test Menu Please select the type of test to execute: 1. DCAN Internal loopback test 2. DCAN External loopback test 3. DCAN Parity test 4. DCAN Tx/Rx test ******************************************************* > Enter your selection: Debug: Internal loopback testing Debug: Number of iterations : 100 Debug: Number of messages transmitted : 100 Debug: Number of messages received : 100 Debug: Number of messages lost : 0 Debug: Number of data mismatch : 0 Debug: Error Status Interrupt : 0 Debug: Message object number : 1 Debug: Direction : Transmit Debug: Number of interrupts received : 100 Debug: Number of messages processed : 100 Debug: Message object number : 2 Debug: Direction : Receive Debug: Number of interrupts received : 100 Debug: Number of messages processed : 100 Debug: Receive & Transmit Measurements Debug: Rx Min:470 Max: 503 Average:476 ticks Debug: Tx Min:459 Max: 1340 Average:474 ticks Debug: Internal loopback testing for 100 iterations Passed Feature: Internal loopback testing: Passed
Runing the DCAN External loopback test I get this on the console and again the same reading on the scope.
[Cortex_R4_0] ******************************************************* CAN Unit Test Menu Please select the type of test to execute: 1. DCAN Internal loopback test 2. DCAN External loopback test 3. DCAN Parity test 4. DCAN Tx/Rx test ******************************************************* > Enter your selection: Debug: External loopback testing Debug: Number of iterations : 100 Debug: Number of messages transmitted : 100 Debug: Number of messages received : 100 Debug: Number of messages lost : 0 Debug: Number of data mismatch : 0 Debug: Error Status Interrupt : 0 Debug: Message object number : 1 Debug: Direction : Transmit Debug: Number of interrupts received : 100 Debug: Number of messages processed : 100 Debug: Message object number : 2 Debug: Direction : Receive Debug: Number of interrupts received : 100 Debug: Number of messages processed : 100 Debug: Receive & Transmit Measurements Debug: Rx Min:463 Max: 1344 Average:478 ticks Debug: Tx Min:459 Max: 476 Average:466 ticks Debug: External loopback testing for 100 iterations Passed Feature: External loopback testing: Passed
Running the DCAN Parity test I get this on the console and the same reading again on the scope.
[Cortex_R4_0] ******************************************************* CAN Unit Test Menu Please select the type of test to execute: 1. DCAN Internal loopback test 2. DCAN External loopback test 3. DCAN Parity test 4. DCAN Tx/Rx test ******************************************************* > Enter your selection: Debug: parity testing Error: ECC error status check failed. Single bit error 0 Double bit error 1 Message Number 64 Feature: Parity testing: Failed Debug:CAN testing failed
Finally running DCAN Tx/Rx test I see this in the console and still the same on the scope.
[Cortex_R4_0] ******************************************************* CAN Unit Test Menu Please select the type of test to execute: 1. DCAN Internal loopback test 2. DCAN External loopback test 3. DCAN Parity test 4. DCAN Tx/Rx test ******************************************************* > Enter your selection: Debug: External transmit testing Debug: External transmit testing Passed Debug: Number of iterations : 1 Debug: Number of messages transmitted : 0 Debug: Number of messages received : 0 Debug: Number of messages lost : 0 Debug: Error Status Interrupt : 1 Debug: Message object number : 1 Debug: Direction : Transmit Debug: Number of interrupts received : 0 Debug: Number of messages processed : 1 Debug: Message object number : 2 Debug: Direction : Receive Debug: Number of interrupts received : 0 Debug: Number of messages processed : 0 Debug: Receive passive error : 0 Debug: Transmit Error Counter : 136 Debug: Receive Error Counter : 0
Does this provide insight as to what the problem might be?
In reply to Tim Dunham:
Hi Tim,
Going through the description in your previous post, it is not clear if you've followed the required ECOs as mentioned in Appendix A.4 of the following app note:
CAN Node on AWR1642
Could you please confirm if you've mounted 0 ohm resistor on R11 and R12 and removed R6 and R4 as required?
Regards
-Nitin
I am using the IWR1642BOOST EVM so I followed the instructions in section 2.3.3 of that user guide http://www.ti.com/lit/ug/swru521b/swru521b.pdf and mounted 0 ohms on R11 and R12 and removed R4, R6, R28 and R63.
Additionally, I have now tried runng the CANFD driver unit test and found that works and shows the expected output on the scope so I have tried changeing my program to use CANFD rather than CAN. This still is not working but it does give an error message. It is failing to transmit with error code -3502, which I think is EINUSE meaning the last message is still being sent? I am only calling CANFD_transmitData() once per frame so there should be long enough between sending the messages?
You'll need an MMWAVE-DEVPACK to validate the DCAN interface since on both AWR1642BOOST and IWR1642BOOST EVMs, the DCAN lines are routed to the MMWAVE-DEVPACK. Only CAN-FD is exposed on the xWR1642BOOST which is what you got working. You'll also need to perform the ECOs mentioned in CAN Node on AWR1642 for DCAN.
Please mark this thread resolved if your question is answered otherwise get back if more support if needed.
Thanks
/* Wait for the transmit complete interrupt */ while (gTxDoneFlag == 0); gTxDoneFlag = 0;
I am actually still having trouble with using CAN-FD. When I run the EVM test on the CAN-FD driver unit test I do not get any results on the console and I don't see anything on the scope. When I step through the program I find that it is stuck in this while loop on line 1288:
In my program I also have the same while loop to wait for the transmit complete interrupt after the canfd transmit call and it will also get stuck in it. If I remove the loop in my program the first CANFD_transmitData() will run without returning an error but without any data being seen to be transmitted on the scope and subsequent calls will give error code -3502.
These are the results for the other CAN-FD driver tests if they might help diagnose the problem. The external transmit test also seems to give non ideal results.
[Cortex_R4_0] ******************************************************* CANFD Unit Test Menu Please select the type of test to execute: 1. MCAN Internal loopback test 2. MCAN External loopback test 3. MCAN Parity test 4. MCAN External Tx/Rx test 5. MCAN EVM-EVM test 6. MCAN Tx Cancel test 7. MCAN Power down test ******************************************************* > Enter your selection: Debug: Internal loopback testing Debug: Number of iterations : 100 Debug: Number of messages transmitted : 100 Debug: Number of messages received : 100 Debug: Number of messages lost : 0 Debug: Number of data mismatch : 0 Debug: Error Status Interrupt : 0 Debug: Message Identifier : 670 Debug: Direction : Transmit Debug: Number of interrupts received : 100 Debug: Number of messages processed : 100 Debug: Message Identifier : 670 Debug: Direction : Receive Debug: Number of interrupts received : 100 Debug: Number of messages processed : 100 Debug: Receive & Transmit Measurements Debug: Rx Min:1911 Max: 2803 Average:1940 ticks Debug: Tx Min:1090 Max: 1170 Average:1115 ticks Debug: Internal loopback testing for 100 iterations Passed Feature: Internal loopback testing: Passed
[Cortex_R4_0] ******************************************************* CANFD Unit Test Menu Please select the type of test to execute: 1. MCAN Internal loopback test 2. MCAN External loopback test 3. MCAN Parity test 4. MCAN External Tx/Rx test 5. MCAN EVM-EVM test 6. MCAN Tx Cancel test 7. MCAN Power down test ******************************************************* > Enter your selection: Debug: External loopback testing Debug: Number of iterations : 100 Debug: Number of messages transmitted : 100 Debug: Number of messages received : 100 Debug: Number of messages lost : 0 Debug: Number of data mismatch : 0 Debug: Error Status Interrupt : 0 Debug: Message Identifier : 670 Debug: Direction : Transmit Debug: Number of interrupts received : 100 Debug: Number of messages processed : 100 Debug: Message Identifier : 670 Debug: Direction : Receive Debug: Number of interrupts received : 100 Debug: Number of messages processed : 100 Debug: Receive & Transmit Measurements Debug: Rx Min:1911 Max: 2837 Average:1931 ticks Debug: Tx Min:1090 Max: 1181 Average:1107 ticks Debug: External loopback testing for 100 iterations Passed Feature: External loopback testing: Passed
No results for the parity test as it does not seem to exist in the program.
[Cortex_R4_0] ******************************************************* CANFD Unit Test Menu Please select the type of test to execute: 1. MCAN Internal loopback test 2. MCAN External loopback test 3. MCAN Parity test 4. MCAN External Tx/Rx test 5. MCAN EVM-EVM test 6. MCAN Tx Cancel test 7. MCAN Power down test ******************************************************* > Enter your selection: Debug: External transmit testing Debug: Number of iterations : 1 Debug: Number of messages transmitted : 0 Debug: Number of messages received : 0 Debug: Number of messages lost : 0 Debug: Error Status Interrupt : 1 Debug: Message Identifier : 193 Debug: Direction : Transmit Debug: Number of interrupts received : 0 Debug: Number of messages processed : 1 Debug: Message Identifier : 193 Debug: Direction : Receive Debug: Number of interrupts received : 0 Debug: Number of messages processed : 0 Debug: Receive passive status : 0 Debug: Transmit Error Counter : 8 Debug: Receive Error Counter : 0 Debug: Error Logging Counter : 0 Debug: LEC : 7 Debug: Activity : 1 Debug: Error Passive : 0 Debug: Warning Status : 0 Debug: Bus Off Status : 0 Debug: Data Phase LEC : 3 Debug: Rx ESI flag : 0 Debug: Rx BRS flag : 0 Debug: Rx CAN FD : 0 Debug: Protocol Exception Event : 0 Debug: TDC value : 14
[Cortex_R4_0] ******************************************************* CANFD Unit Test Menu Please select the type of test to execute: 1. MCAN Internal loopback test 2. MCAN External loopback test 3. MCAN Parity test 4. MCAN External Tx/Rx test 5. MCAN EVM-EVM test 6. MCAN Tx Cancel test 7. MCAN Power down test ******************************************************* > Enter your selection: Debug: Tx Cancel testing Debug: Number of iterations : 100 Debug: Number of messages transmitted : 100 Debug: Number of messages received : 0 Debug: Number of messages lost : 0 Debug: Number of data mismatch : 0 Debug: Error Status Interrupt : 0 Debug: Message Identifier : 670 Debug: Direction : Transmit Debug: Number of interrupts received : 100 Debug: Number of messages processed : 0 Debug: Message Identifier : 670 Debug: Direction : Receive Debug: Number of interrupts received : 0 Debug: Number of messages processed : 0 Debug: External loopback testing for 100 iterations Passed Feature: Tx Cancel testing: Passed
[Cortex_R4_0] ******************************************************* CANFD Unit Test Menu Please select the type of test to execute: 1. MCAN Internal loopback test 2. MCAN External loopback test 3. MCAN Parity test 4. MCAN External Tx/Rx test 5. MCAN EVM-EVM test 6. MCAN Tx Cancel test 7. MCAN Power down test ******************************************************* > Enter your selection: Debug: Power Down testing Debug: Number of iterations : 100 Debug: Number of messages transmitted : 100 Debug: Number of messages received : 100 Debug: Number of messages lost : 0 Debug: Number of data mismatch : 0 Debug: Error Status Interrupt : 0 Debug: Message Identifier : 670 Debug: Direction : Transmit Debug: Number of interrupts received : 100 Debug: Number of messages processed : 100 Debug: Message Identifier : 670 Debug: Direction : Receive Debug: Number of interrupts received : 100 Debug: Number of messages processed : 100 Debug: CANFD Module Power Down sucessful Debug: CANFD Module is Wake Up sucessful Debug: Number of iterations : 100 Debug: Number of messages transmitted : 200 Debug: Number of messages received : 200 Debug: Number of messages lost : 0 Debug: Number of data mismatch : 0 Debug: Error Status Interrupt : 0 Debug: Message Identifier : 670 Debug: Direction : Transmit Debug: Number of interrupts received : 200 Debug: Number of messages processed : 200 Debug: Message Identifier : 670 Debug: Direction : Receive Debug: Number of interrupts received : 200 Debug: Number of messages processed : 200 Feature: Power Down testing: Passed
So the DCAN lines will be routed through the CAN connector J3 on the IWR1642BOOST EVM and the MMWAVE-DEVPACK is not necessary?
Yes, I am still having issues running the DCAN driver test. I get these results for each of the tests:
1: Internal loopback
[Cortex_R4_0] ******************************************************* CAN Unit Test Menu Please select the type of test to execute: 1. DCAN Internal loopback test 2. DCAN External loopback test 3. DCAN Parity test 4. DCAN Tx/Rx test ******************************************************* > Enter your selection: Debug: Internal loopback testing Debug: Number of iterations : 100 Debug: Number of messages transmitted : 100 Debug: Number of messages received : 100 Debug: Number of messages lost : 0 Debug: Number of data mismatch : 0 Debug: Error Status Interrupt : 0 Debug: Message object number : 1 Debug: Direction : Transmit Debug: Number of interrupts received : 100 Debug: Number of messages processed : 100 Debug: Message object number : 2 Debug: Direction : Receive Debug: Number of interrupts received : 100 Debug: Number of messages processed : 100 Debug: Receive & Transmit Measurements Debug: Rx Min:470 Max: 503 Average:476 ticks Debug: Tx Min:455 Max: 468 Average:461 ticks Debug: Internal loopback testing for 100 iterations Passed Feature: Internal loopback testing: Passed
2: External loopback
[Cortex_R4_0] ******************************************************* CAN Unit Test Menu Please select the type of test to execute: 1. DCAN Internal loopback test 2. DCAN External loopback test 3. DCAN Parity test 4. DCAN Tx/Rx test ******************************************************* > Enter your selection: Debug: External loopback testing Debug: Number of iterations : 100 Debug: Number of messages transmitted : 100 Debug: Number of messages received : 100 Debug: Number of messages lost : 0 Debug: Number of data mismatch : 0 Debug: Error Status Interrupt : 0 Debug: Message object number : 1 Debug: Direction : Transmit Debug: Number of interrupts received : 100 Debug: Number of messages processed : 100 Debug: Message object number : 2 Debug: Direction : Receive Debug: Number of interrupts received : 100 Debug: Number of messages processed : 100 Debug: Receive & Transmit Measurements Debug: Rx Min:463 Max: 1327 Average:478 ticks Debug: Tx Min:459 Max: 1342 Average:475 ticks Debug: External loopback testing for 100 iterations Passed Feature: External loopback testing: Passed
3: Parity
CAN Unit Test Menu Please select the type of test to execute: 1. DCAN Internal loopback test 2. DCAN External loopback test 3. DCAN Parity test 4. DCAN Tx/Rx test ******************************************************* > Enter your selection: Debug: parity testing Error: ECC error status check failed. Single bit error 0 Double bit error 1 Message Number 64 Feature: Parity testing: Failed Debug:CAN testing failed
4: External Transmit