Hey
I m working with TMS320F28335 connected to a PCAN usb. what im trying to do is create a program that sends messages from CAN A to PCAN and also receives Messages from PCAN to CAN A. The transmitting of the messagues works fine wheareas when i try to send a message from PCAN to CAN A it never reaches the mailbox. are there any ideas as to why this might happen. I have configured Mailbox 8 as the receive mailbox and mailbox 4 as the transmit one, here s my code:
/*--------------------------------------------------------------------------------------------------------------------*/
// Can A Reception and Tranmition to/From PCAN //
/*--------------------------------------------------------------------------------------------------------------------*/
// Description:
/* The program configures Mailbox 8 In CAN A to Receive Messages from P_CAN and Mailbox 4 to Transmit to PCAN*/
#include "DSP2833x_Device.h"
#include "DSP2833x_Examples.h"
struct ECAN_REGS ECanaShadow;
Uint16 MessageCount=0;
void main()
{
// Initialize the System
InitSysCtrl();
//Initialize GPIO for eCan
InitECanGpio();
//Pie Control Registers are initialized to their default state
InitPieCtrl();
// Enable CPU interrupts and clear all CPU interrupt flags:
// EnableInterrupts();
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
InitPieVectTable();
// Initialize CAN A and CAN B
InitECan();
/*---------------------------------Start Receive and Transmit Configurations Configuration------------------------------*/
// For the Transmit Mailbox Clear The CANTRS register
ECanaShadow.CANTRR.all=ECanaRegs.CANTRR.all;
ECanaShadow.CANTRR.bit.TRR4=1;
ECanaRegs.CANTRR.all=ECanaShadow.CANTRR.all;
// Wait until TRS bit clears
do
{ ECanaShadow.CANTRS.all=ECanaRegs.CANTRS.all;
} while(ECanaShadow.CANTRS.bit.TRS4!=0);
//Dissable Mailbox
ECanaShadow.CANME.all=ECanaRegs.CANME.all;
ECanaShadow.CANME.bit.ME4=0;
ECanaShadow.CANME.bit.ME8=0;
ECanaRegs.CANME.all=ECanaShadow.CANME.all;
//Write Identifier in the Identifier Field
//Mailbox 4
ECanaMboxes.MBOX4.MSGID.all=0x0000BBCC;
ECanaMboxes.MBOX4.MSGID.bit.IDE=1;
ECanaMboxes.MBOX4.MSGID.bit.AAM=0;
ECanaMboxes.MBOX4.MSGID.bit.AME=0;
//Mailbox 8
ECanaMboxes.MBOX8.MSGID.all=0x0000AACC;
ECanaMboxes.MBOX8.MSGID.bit.IDE=1;
ECanaMboxes.MBOX8.MSGID.bit.AME=0;
//Writting the Data Lenght
ECanaMboxes.MBOX4.MSGCTRL.bit.DLC=8;
//Configure the Mailbox In Receive Direction
ECanaShadow.CANMD.all=ECanaRegs.CANMD.all;
ECanaShadow.CANMD.bit.MD4=0;
ECanaShadow.CANMD.bit.MD8=1;
ECanaRegs.CANMD.all=ECanaShadow.CANMD.all;
//Enable Mailbox
ECanaShadow.CANME.all=ECanaRegs.CANME.all;
ECanaShadow.CANME.bit.ME4=1;
ECanaShadow.CANME.bit.ME8=1;
ECanaRegs.CANME.all=ECanaShadow.CANME.all;
//----------------------------------------Start Transmission---------------------------------------------------------//
//Write The message data into the Mailbox Data Field
ECanaMboxes.MBOX4.MDL.all= 0xAAAAAAAA;
ECanaMboxes.MBOX4.MDH.all= 0x00000000;
for(;;)
{
ECanaShadow.CANTRS.all=ECanaRegs.CANTRS.all;
ECanaShadow.CANTRS.bit.TRS4=1;
ECanaRegs.CANTRS.all=ECanaShadow.CANTRS.all;
do{
ECanaShadow.CANTA.all=ECanaRegs.CANTA.all;
} while(ECanaShadow.CANTA.bit.TA4==0);
ECanaShadow.CANTA.all= ECanaRegs.CANTA.all;
ECanaShadow.CANTA.bit.TA4= 1;
ECanaRegs.CANTA.all=ECanaShadow.CANTA.all;
do{
ECanaShadow.CANTA.all=ECanaRegs.CANTA.all;
} while(ECanaShadow.CANTA.bit.TA4!=0);
MessageCount++;
}
}