• AVR Freaks

Hot!Enabling CAN TX in dsPIC33EV32GM104 but getting TRAPS_halt_on_error fault while debugging

Author
vijayakumar.sargunam
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2012/10/12 22:59:47
  • Location: 0
  • Status: offline
2021/01/22 02:38:22 (permalink)
0

Enabling CAN TX in dsPIC33EV32GM104 but getting TRAPS_halt_on_error fault while debugging

Hi,
 
      I am checking the CAN module of dsPIC33EV32GM104. CAN example code generated through MCC plugin,while debugging the code, the debugger halts at TRAPS_on_error inside traps.c. Here is the code. I set the breakpoint near CAN1_Transmit(CAN_PRIORITY_HIGH, &txCanMsg);
 
#include "mcc_generated_files/system.h"
#include "mcc_generated_files/can1.h"
//#pragma config ICS = PGD2
//_FICD(ICS_PGD2);
int main(void)
{
 uint8_t data[8] = {0};
 //uint8_t msgObjData[8] = {0,1,2,3,4,5,6,7};
 CAN_MSG_OBJ rxCanMsg;
 rxCanMsg.data = data;
 CAN_MSG_OBJ txCanMsg;
 //txCanMsg.data = msgObjData;
 
 
 // initialize the device
 SYSTEM_Initialize();
 INTCON2bits.GIE = true;
 CAN1_TransmitEnable();
 CAN1_ReceiveEnable();
 CAN1_OperationModeSet(CAN_CONFIGURATION_MODE);
 txCanMsg.msgId = 0x220;
 txCanMsg.field.idType = CAN_FRAME_STD;
 txCanMsg.field.frameType = CAN_FRAME_DATA;
 txCanMsg.field.dlc = CAN_DLC_8;
         // txCanMsg.data = msgObjData;
 txCanMsg.data[0] =0x20;
 txCanMsg.data[1] =0x30;
 txCanMsg.data[2] =0x40;
 txCanMsg.data[3] =0x50;
 txCanMsg.data[4] =0x60;
 txCanMsg.data[5] =0x70;
 txCanMsg.data[6] =0x70;
 txCanMsg.data[7] =0x70;
 
 
 if(CAN_CONFIGURATION_MODE == CAN1_OperationModeGet())
 {
  if(CAN_OP_MODE_REQUEST_SUCCESS == CAN1_OperationModeSet(CAN_NORMAL_2_0_MODE))
  {
   while(1)
   {
            
          CAN1_Transmit(CAN_PRIORITY_HIGH, &txCanMsg);
   }
  }
 }

 while(1);
 return 0;
}

 
 
post edited by vijayakumar.sargunam - 2021/01/22 03:44:02
#1

1 Reply Related Threads

    ric
    Super Member
    • Total Posts : 29861
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Enabling CAN TX in dsPIC33EV32GM104 2021/01/22 03:18:23 (permalink)

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    Jump to:
    © 2021 APG vNext Commercial Version 4.5