Other Parts Discussed in Thread: HALCOGEN, ISO1042DWEVM
I'm using the Launchpad to try to send and receive CAN messages with the PCan-View software. I am using the ISO1042DWEVM transceiver module. It will send messages from the TX message boxes, but the RX boxes won't receive their messages. Here's the setup in HalCoGen:
I've setup the first four mailboxes in a similar way to the example.
Here's the code I'm using:
/* USER CODE BEGIN (0) */ /* USER CODE END */ /* Include Files */ #include "sys_common.h" /* USER CODE BEGIN (1) */ #include "system.h" #include "can.h" #include "esm.h" #define D_SIZE 9 uint8 tx_data[D_SIZE] = {'H','E','R','C','U','L','E','S','\0'}; uint8 tx_data1[D_SIZE] = {0x4, 0x7, 0x0, 0x0, 0x4, 0x7, 0x0, 0x0, 0x0}; uint8 tx_data2[D_SIZE] = {0x5, 0x7, 0x0, 0x0, 0x5, 0x7, 0x0, 0x0, 0x0}; uint8 rx_data[D_SIZE] = {0}; uint32 error = 0; uint32 checkPackets(uint8 *src_packet,uint8 *dst_packet,uint32 psize); /* USER CODE END */ /** @fn void main(void) * @brief Application main function * @note This function is empty by default. * * This function is called after startup. * The user can use this function to implement the application. */ /* USER CODE BEGIN (2) */ /* USER CODE END */ int main(void) { /* USER CODE BEGIN (3) */ /* initialize can 1 and 2 */ canInit(); /* can1 -> can2 */ /* transmit on can1 */ canTransmit(canREG1, canMESSAGE_BOX1, tx_data); canTransmit(canREG1, canMESSAGE_BOX2, tx_data1); canTransmit(canREG1, canMESSAGE_BOX3, tx_data2); /*... wait until message receive on can1 */ while(!canIsRxMessageArrived(canREG1, canMESSAGE_BOX4)); canGetData(canREG1, canMESSAGE_BOX4, rx_data); /* receive on can1 */ /* check received data patterns */ //error = checkPackets(&tx_data[0],&rx_data[0],D_SIZE); canTransmit(canREG1, canMESSAGE_BOX2, rx_data); /* ... run forever */ while(1); /* USER CODE END */ return 0; }
My problem is that I can run the program, it will send the messages from message boxes 1,2, and 3, but when I am sending a constant message from PCan-View with message ID 0x2, it is continually stuck in the while loop waiting for an RX message to arrive.
I have been able to get a PSoC microcontroller to receive the message from PCan-View, but the TI processor seems unresponsive to receiving messages. Is there something different I need to change in the initialization of the CAN on the processor or some other code I need to use? I haven't set up the processor to use interrupt based CAN.