surendran_raj
Junior Member level 2
I tried to transmit data using CAN communication in dsPIC33CK64MP508. I use MCC for configuring CAN in dsPIC33CK64MP508 and MCP2551 CAN transceiver. I set the bit rate to 500 kbps. I just transmit two data bytes (0x41 and 0x42) and I used a logic analyzer to view the data but it shows the error.
I have attached my output data using a logic analyzer. Can anyone please correct me?
output in Logic analyzer
I have attached my output data using a logic analyzer. Can anyone please correct me?
Code:
int main(void)
{
// initialize the device
CAN_MSG_OBJ msg;
uint8_t data[2] = {0x41,0x42};
SYSTEM_Initialize();
CAN1_OperationModeSet(CAN_CONFIGURATION_MODE);
if(CAN_CONFIGURATION_MODE == CAN1_OperationModeGet())
{
if(CAN_OP_MODE_REQUEST_SUCCESS == CAN1_OperationModeSet(CAN_NORMAL_2_0_MODE))
{
msg.msgId = 0x1FFFF;
msg.field.formatType = CAN_2_0_FORMAT;
msg.field.brs = CAN_NON_BRS_MODE;
msg.field.frameType = CAN_FRAME_DATA;
msg.field.idType = CAN_FRAME_EXT;
msg.field.dlc = 2;
msg.data = data;
if(CAN1_IsBusOff() == false)
{
if(CAN_TX_FIFO_AVAILABLE == (CAN1_TransmitFIFOStatusGet(CAN1_TX_FIFO1) & CAN_TX_FIFO_AVAILABLE))
{
CAN1_Transmit(CAN1_TX_FIFO1, &msg);
}
}
}
}
while (1)
{
// Add your application code
}
return 1;
}
output in Logic analyzer