• AVR Freaks

Hot!Testing CAN module in dsPIC33EV32GM104

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 01:51:41 (permalink)
0

Testing CAN module in dsPIC33EV32GM104

Hi,
 
      I try to transmit CAN message from dsPIC33EV32GM104 controller. I written the code and compiled it, but i am not getting any signal in the C1TX pin. I checked through CAN analyzer also but unsuccessful. I created a MCC plugin based CAN project. Here is my code. Help me find the issue. Plz sugggest any example code to test the CAN module of dsPIC33EV32GM104 controller.
 
#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 = data;
 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)
   {
   // if(CAN1_ReceivedMessageCountGet() > 0)
   // {
    // if(true == CAN1_Receive(&rxCanMsg))
    // {
     // if(rxCanMsg.msgId == 0x108)
      //{
   
          
          
          CAN1_Transmit(CAN_PRIORITY_HIGH, &txCanMsg);
     // }
     //}
    //}
   }
  }
 }

 while(1);
 return 0;
}
 
#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: online
    Re: Testing CAN module in dsPIC33EV32GM104 2021/01/22 03:17:51 (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