Hi.
I'm trying to send images processed in DM6437 by CAN bus at 500kbps. I use one PRD (periodic funcion) to send at least of 1 image/sec, with size of around 15kB. I have enough bandwith to trasfer this amount of data, but I realized that I need doing active waiting for send each CAN frame.I tested controller can't send more than 1 CAN frame each 250 us). For example if I do directly:
for (i=0 ;i<(IMAGE_SIZE/7) ;i++ )
{
if (numSec==257)
{
numSec=0;
}
tx_data_low = numSec<<24;
numSec++;
tx_data_high=0;
for (j=0;j<7;j++)
{
if (j<3)
{
tx_data_low |= (0xFF & PICBMP[j+numFrames*7])<<(16-(j*8));
}
else
{
tx_data_high|= (0xFF & PICBMP[j+numFrames*7])<<(24-((j-3)*8));
}
}
/* -------------------------------- *
* Transmit data async *
* -------------------------------- */
can_tx_setup( mailboxSelected, msg_id_TX_2, DATA_LENGTH_8, PRIORITY_0 );
can_tx( mailboxSelected, tx_data_low, tx_data_high );
mailboxSelected++;
if (mailboxSelected==3)
{
mailboxSelected=1;
}
}
where functions realated are:
/* ------------------------------------------------------------------------ *
* can_tx_setup( ) *
* ------------------------------------------------------------------------ */
Int16 can_tx_setup( Uint32 mailbox, Uint32 msg_id, Uint32 tx_length, Int32 tx_priority )
{
Uint32 mailbox_bit = 1 << mailbox;
tx_priority = tx_priority & 0x3F;
tx_length = tx_length & 0x0F;
hecc->regs->ME &= ~mailbox_bit; // Disable mailbox
tx_msg_idreg = 0
| ( STANDARD_ID << 31 ) // Set the identifier type
| ( 0 << 30 ) // Clear Acceptance Mask Enable( AME )
| ( 0 << 29 ) // Auto-Answer mode( AAM )
| ( msg_id << 0 ); // Load the identifier
tx_msg_mcfreg = 0
| ( tx_priority << 8 ) // Set Priority
| ( 0 << 4 ) // No Remote Frame
| ( tx_length << 0 ); // Data length
hecc->regs->MD &= ~mailbox_bit; // Set transmit mode
hecc->regs->ME |= mailbox_bit; // Enable mailbox
hecc->regs->TA == 0;
return 0;
}
/* ------------------------------------------------------------------------ *
* can_tx( ) *
* ------------------------------------------------------------------------ */
Int16 can_tx( Uint32 mailbox, Uint32 low, Uint32 high )
{
Uint32 mailbox_bit = 1 << mailbox;
/* Write into Mailbox# */
hecc->regs->ME &= ~mailbox_bit; // Disable MBX
hecc->regs->MBX[mailbox].MID = tx_msg_idreg;
// hecc->regs->ME |= mailbox_bit; // Enable MBX
hecc->regs->ME = mailbox_bit; // Enable MBX
hecc->regs->MBX[mailbox].MCF = tx_msg_mcfreg;
hecc->regs->MBX[mailbox].MDL = low;
hecc->regs->MBX[mailbox].MDH = high;
/* Start transmission */
hecc->regs->TRS |= mailbox_bit;
while( hecc->regs->TA == 0 );
return 0;
}
With that code, I lost some frame (it seems the controller is not quick enough and overwrite the mailboxes). TO resolve I need to put a delay of minimum of 250us.. in each iteration.
Could I increase this performance???
Thank a lot