dsPIC33E CAN transmission failure
I am using the dsPIC33EV 5V CAN-LIN STARTER KIT
to get acquainted with the use of CAN protocol with dsPIC33E architecture. I tested the Demo Code, given by Microchip, which implements CAN message transmission, with the board connected to a PCAN-USB reader
. Everything runs smoothly and I correctly see the CAN packets sent by the board.
I decided then to proceed with the implementation of CAN within one of my project, in which simply the dsPIC reads periodically a sensor through I2C (that part perfectly functioning). The basic version of the project expected the data read through I2C to be transmitted to the PC through UART, the next step I wished to implement was to substitute the UART with a CAN transmission to the PC connected to the PCAN-USB reader.
I implemented CAN and DMA libraries given by MPLABX Code Configurator (yeah, I know, I should avoid it, but so far it worked pretty good for all the rest of functionalities I have implemented), double-checking the consistency and correctness of the APIs with the Microchip reference manuals dedicated to DMA (DS70348C) and CAN (DS70353C), as well as with the Application Note AN1249 (which is the reference followed for development of the Demo Code above mentioned).
To start with something easy, I simply implemented a single CAN transmission of 8 bytes containing 0x55 each.
Nonetheless, the CAN transmission is not working and inspecting with the debugger I've found out that when the CAN transmission is requested, by setting the flag C1TR01CONbits.TXREQ,
it is contextually set also the the flag C1TR01CONbits.TXERR,
which indicates that 'a bus error occurred while the message was being sent'.
Generally speaking, which could be the cause generating this error?
I have to ask the question this way because after two days of controlling the code I simply don't know what else I could check. To avoid a cluttered post I avoided on purpose to insert chunks of code but I am available to share specific parts if this could help (e.g. CAN and DMA Init).
Thanks in advance.
post edited by edga - 2019/07/25 09:40:35