Drugo
Junior Member level 2
Hello community, I'm having an issue implementing View attachment AN1249_dsPIC33F.zipin order to implement CAN bus with DMA and ECAN on dsPIC33F. It's driving me crazy! :bang::bang::bang: I have to deliver my CAN bus driver in 3 days and am really in trouble. :fight: The issue is related to the ISR routine, that never gets activated. Or better, the TX interrupt never gets activated (C1INTFbits.TBIF is always zero). I do not have a CAN simulator to transmit a message in order to debug the RX ISR portion of the code.
I'm using dsPIC33FJ256GP710A (as a transmitter) and dsPIC33FJ128GP706A (as a receiver) devices. These are the devices I'm going to use in my final application. Just for simplicity, I use one device just to transmit and the other one just to receive.
The code I am working on (here attached) is the same of AN1249, except that I used a CAN bit rate of 100 kbps (the final system will work at this speed and won't use terminator resistors) and deleted all parts related to the LCD (I don't have one in my system). Having used a bit rate of 100 kbps, instead of the AN1249 default one (1Mbit), in my opinion all the configuration parameters of the ECAN controller remain the same (like SJW, SEG1PH, SEG2PHTS, SEG2PH, PRSEG, SAM, etc.).
Buffer 1, in the initECAN( ), is initialized as standard CAN to receive message ID = 0x123. Since I use the same code in two devices, one is the transmitter and one is the receiver, I used two #defines in order to distinguish the transmitter of standard ID = 0x123 (buffer 1) and the receiver of standard ID = 0x123 (buffer 1) (the #defines are, respectively, THIS_IS_THE_TRANSMITTER and THIS_IS_THE_RECEIVER). Because of that, in the main( ) before the infinite for(;, i used 'canTxMessage.frame_type = CAN_FRAME_STD' and NOT 'canTxMessage.frame_type = CAN_FRAME_EXT' as the default code.
Does anyone know the reason why, when I transmit the msg (ID = 0x123), the ISR never gets activated? I tried to read the datasheet of both ECAN and DMA modules but haven't found the reason of that. Any help would be really appreciated. :roll:
Thanks to all for your help! :thumbsup:
Regards
I'm using dsPIC33FJ256GP710A (as a transmitter) and dsPIC33FJ128GP706A (as a receiver) devices. These are the devices I'm going to use in my final application. Just for simplicity, I use one device just to transmit and the other one just to receive.
The code I am working on (here attached) is the same of AN1249, except that I used a CAN bit rate of 100 kbps (the final system will work at this speed and won't use terminator resistors) and deleted all parts related to the LCD (I don't have one in my system). Having used a bit rate of 100 kbps, instead of the AN1249 default one (1Mbit), in my opinion all the configuration parameters of the ECAN controller remain the same (like SJW, SEG1PH, SEG2PHTS, SEG2PH, PRSEG, SAM, etc.).
Buffer 1, in the initECAN( ), is initialized as standard CAN to receive message ID = 0x123. Since I use the same code in two devices, one is the transmitter and one is the receiver, I used two #defines in order to distinguish the transmitter of standard ID = 0x123 (buffer 1) and the receiver of standard ID = 0x123 (buffer 1) (the #defines are, respectively, THIS_IS_THE_TRANSMITTER and THIS_IS_THE_RECEIVER). Because of that, in the main( ) before the infinite for(;, i used 'canTxMessage.frame_type = CAN_FRAME_STD' and NOT 'canTxMessage.frame_type = CAN_FRAME_EXT' as the default code.
Does anyone know the reason why, when I transmit the msg (ID = 0x123), the ISR never gets activated? I tried to read the datasheet of both ECAN and DMA modules but haven't found the reason of that. Any help would be really appreciated. :roll:
Thanks to all for your help! :thumbsup:
Regards