DSPRelated.com
Forums

CAN TX PROBLEM WITH 56F83232EVM

Started by simo...@hotmail.com May 10, 2006
Hi to everybody,

I'm a young electronical engeneer and i'm using for the first time an EVM with 56f83232. I try to configure the flexcan module following the instrustion on the chapter 7 of the 56f8300 peripheral user manual and i also have an example bean to help me in the initialization.
My CAN1_Init() function is :

void CAN1_Init()
{
setRegBit(FCMCR, SOFT_RST); /* Soft-reset of the FlexCAN
while(!getRegBit(FCMCR, FREEZ_ACK)){} /* Wait for entering the debug

setRegBit(FCMAXMB, MAXMB0);
setRegBit(FCMAXMB, MAXMB1);
clrRegBit(FCMAXMB, MAXMB2);
clrRegBit(FCMAXMB, MAXMB3);

setReg16(FCCTL0, 2); /* Set the Control 0 register */

// Initialization of all message buffers
setReg(FCMB0_Control, 64);
setReg(FCMB0_ID_HIGH, 0);
setReg(FCMB0_ID_LOW,0);
setReg(FCMB1_Control, 64);
setReg(FCMB1_ID_HIGH, 0);
setReg(FCMB1_ID_LOW,0);

setReg(FCMB2_Control, 0);
setReg(FCMB2_ID_HIGH, 0);

// FCRXGMASK_L:
setReg16(FCRXGMASK_L, 0);

// FCRXGMASK_H:
setReg16(FCRXGMASK_H, 57352);

// FCRX14MASK_L:
setReg16(FCRX14MASK_L, 65534);

// FCRX14MASK_H:
setReg16(FCRX14MASK_H, 65519);

// FCRX15MASK_L:
setReg16(FCRX15MASK_L, 65534);

// FCRX15MASK_H:
setReg16(FCRX15MASK_H, 65519);
setReg16(FCCTL1, 2304);
clrRegBits(FCMCR,FCMCR_HALT_MASK | FCMCR_FRZ1_MASK);
getReg(FCIFLAG1); /* Dumy read of the MB interrupt
setReg(FCIFLAG1,0xFFFF);

// FCIMASK1:
setReg16(FCIMASK1, 4);

setRegBits(FCSTATUS,7); /* Reset interrupt flags */
setRegBits(FCCTL0,(FCCTL0_BUSOFF_MASK_MASK)); /* Enable interrupts */

}

To test the transmission i put on MB2 registers the data and i give the tx code on FCMB control.

setReg(FCMB2_Control, 0x0080);

setReg(FCMB2_ID_HIGH, 0);
setReg(FCMB2_DATA0, 0x0000);
setReg(FCMB2_DATA1, 0xFFFF);
setReg(FCMB2_DATA2, 0x0000);
setReg(FCMB2_DATA3, 0xFFFF);
setReg(FCMB2_Control, 0x00C8);

I check with the oscilloscope and i see the transmission but the device
continue the transmission continuously ,and i'm not able to see the interrupt of succesfull transmission.
There is someone who can give me a hand solving this problem or giving me some suggestion?

Cheers
SIMONE BENATTI
Try this code which someone posted before

//CAN initialization
void init()
{
unsigned int timer;

//soft reset
FCMCR |= 0x0200;

//initialize all operation modes
FCCTL0 &=~ 0x0007;
FCCTL1 = 0x2FDB; // 125K
FCMAXMB = 0x0002;

//initialize message buffer
FCMB0_Control = 0;
FCMB1_Control = 0;
FCMB2_Control = 0;
FCMB3_Control = 0;
FCMB4_Control = 0;
FCMB5_Control = 0;
FCMB6_Control = 0;
FCMB7_Control = 0;
FCMB8_Control = 0;
FCMB9_Control = 0;
FCMB10_Control = 0;
FCMB11_Control = 0;
FCMB12_Control = 0;
FCMB13_Control = 0;
FCMB14_Control = 0;
FCMB15_Control = 0;

//initialize MASK registers
FCRXGMASK_H = 0x0000;
FCRXGMASK_L = 0x0000;

// Configure MB1 for RX
FCMB1_ID_HIGH = 0xC7EE; // MB1 = RX, Ext. ID
FCMB1_ID_LOW = 0x003C; // CAN ID =0x18FF001E,
Data Frame

//initialize interrupt handler
FCCTL0 |= 0xC000; //Enable busoff interrupt and
error interrupt

//clear HALF bit in FC_MCR
FCMCR = 0x0000;

timer = FCTIMER; // Read free running timer to
unlock MB

timer=0;
while((FCMCR&0x0800)==0x800){
if(timer++>=0x6000)
break;
}
}

// CAN transimssion
void can_tx()
{ unsigned int n,status;

FCMB0_Control |= 0x0080; //MB0 is inactive
// Configure MB0 for TX
FCMB0_ID_HIGH = 0xC7FE; // MB0 = TX, Ext. ID
FCMB0_ID_LOW = 0x003C; // CAN ID =0x18FF001E,
Data Frame
FCMB0_ID_HIGH |= 0x0018; //IDE = 1 & SRR = 1;
FCMB0_ID_LOW &=~ 0x0001; //RTR = 0;

// Copy Tx data bytes to the message buffer
FCMB0_DATA0 = CANTxMsg[0].i;
FCMB0_DATA1 = CANTxMsg[1].i;
FCMB0_DATA2 = CANTxMsg[2].i;
FCMB0_DATA3 = CANTxMsg[3].i;

FCMB0_Control |= 0x00C8; //Length of the data
= 8

status = FCIFLAG1;
n=0;
while((status & 0x0001)!=1) // polling
{
if(n++>0x6000)
break;
status = FCIFLAG1;
}
}
Charlie

--- s...@hotmail.com wrote:

> Hi to everybody,
>
> I'm a young electronical engeneer and i'm using for
> the first time an EVM with 56f83232. I try to
> configure the flexcan module following the
> instrustion on the chapter 7 of the 56f8300
> peripheral user manual and i also have an example
> bean to help me in the initialization.
> My CAN1_Init() function is :
>
> void CAN1_Init()
> {
> setRegBit(FCMCR, SOFT_RST); /* Soft-reset
> of the FlexCAN
> while(!getRegBit(FCMCR, FREEZ_ACK)){} /* Wait for
> entering the debug
>
> setRegBit(FCMAXMB, MAXMB0);
> setRegBit(FCMAXMB, MAXMB1);
> clrRegBit(FCMAXMB, MAXMB2);
> clrRegBit(FCMAXMB, MAXMB3);
>
> setReg16(FCCTL0, 2); /* Set the
> Control 0 register */
>
>
> // Initialization of all message buffers
> setReg(FCMB0_Control, 64);
> setReg(FCMB0_ID_HIGH, 0);
> setReg(FCMB0_ID_LOW,0);
> setReg(FCMB1_Control, 64);
> setReg(FCMB1_ID_HIGH, 0);
> setReg(FCMB1_ID_LOW,0);
>
> setReg(FCMB2_Control, 0);
> setReg(FCMB2_ID_HIGH, 0);
>
>
>
> // FCRXGMASK_L:
> setReg16(FCRXGMASK_L, 0);
>
> // FCRXGMASK_H:
> setReg16(FCRXGMASK_H, 57352);
>
> // FCRX14MASK_L:
> setReg16(FCRX14MASK_L, 65534);
>
> // FCRX14MASK_H:
> setReg16(FCRX14MASK_H, 65519);
>
> // FCRX15MASK_L:
> setReg16(FCRX15MASK_L, 65534);
>
> // FCRX15MASK_H:
> setReg16(FCRX15MASK_H, 65519);
> setReg16(FCCTL1, 2304);
> clrRegBits(FCMCR,FCMCR_HALT_MASK |
> FCMCR_FRZ1_MASK);
> getReg(FCIFLAG1); /* Dumy read of
> the MB interrupt
> setReg(FCIFLAG1,0xFFFF);
>
> // FCIMASK1:
> setReg16(FCIMASK1, 4);
>
>
> setRegBits(FCSTATUS,7); /* Reset interrupt flags
> */
> setRegBits(FCCTL0,(FCCTL0_BUSOFF_MASK_MASK)); /*
> Enable interrupts */
>
> }
>
> To test the transmission i put on MB2 registers the
> data and i give the tx code on FCMB control.
>
> setReg(FCMB2_Control, 0x0080);
>
> setReg(FCMB2_ID_HIGH, 0);
> setReg(FCMB2_DATA0, 0x0000);
> setReg(FCMB2_DATA1, 0xFFFF);
> setReg(FCMB2_DATA2, 0x0000);
> setReg(FCMB2_DATA3, 0xFFFF);
> setReg(FCMB2_Control, 0x00C8);
>
>
> I check with the oscilloscope and i see the
> transmission but the device
> continue the transmission continuously ,and i'm not
> able to see the interrupt of succesfull
> transmission.
> There is someone who can give me a hand solving
> this problem or giving me some suggestion?
>
> Cheers
> SIMONE BENATTI
__________________________________________________
Hi,

You probably have no connected another CAN device to the CAN bus and the
CAN device tries to deliver a message to an another CAN node. When the
CAN bus is configured correctly, you should see only one frame to be
transmitted on the oscilloscope.

S pozdravem,

Marek Vinkler
m...@atlas.cz

s...@hotmail.com wrote:
> Hi to everybody,
>
> I'm a young electronical engeneer and i'm using for the first time an EVM with 56f83232. I try to configure the flexcan module following the instrustion on the chapter 7 of the 56f8300 peripheral user manual and i also have an example bean to help me in the initialization.
> My CAN1_Init() function is :
>
> void CAN1_Init()
> {
> setRegBit(FCMCR, SOFT_RST); /* Soft-reset of the FlexCAN
> while(!getRegBit(FCMCR, FREEZ_ACK)){} /* Wait for entering the debug
>
> setRegBit(FCMAXMB, MAXMB0);
> setRegBit(FCMAXMB, MAXMB1);
> clrRegBit(FCMAXMB, MAXMB2);
> clrRegBit(FCMAXMB, MAXMB3);
>
> setReg16(FCCTL0, 2); /* Set the Control 0 register */
>
>
> // Initialization of all message buffers
> setReg(FCMB0_Control, 64);
> setReg(FCMB0_ID_HIGH, 0);
> setReg(FCMB0_ID_LOW,0);
> setReg(FCMB1_Control, 64);
> setReg(FCMB1_ID_HIGH, 0);
> setReg(FCMB1_ID_LOW,0);
>
> setReg(FCMB2_Control, 0);
> setReg(FCMB2_ID_HIGH, 0);
>
>
>
> // FCRXGMASK_L:
> setReg16(FCRXGMASK_L, 0);
>
> // FCRXGMASK_H:
> setReg16(FCRXGMASK_H, 57352);
>
> // FCRX14MASK_L:
> setReg16(FCRX14MASK_L, 65534);
>
> // FCRX14MASK_H:
> setReg16(FCRX14MASK_H, 65519);
>
> // FCRX15MASK_L:
> setReg16(FCRX15MASK_L, 65534);
>
> // FCRX15MASK_H:
> setReg16(FCRX15MASK_H, 65519);
> setReg16(FCCTL1, 2304);
> clrRegBits(FCMCR,FCMCR_HALT_MASK | FCMCR_FRZ1_MASK);
> getReg(FCIFLAG1); /* Dumy read of the MB interrupt
> setReg(FCIFLAG1,0xFFFF);
>
> // FCIMASK1:
> setReg16(FCIMASK1, 4);
>
>
> setRegBits(FCSTATUS,7); /* Reset interrupt flags */
> setRegBits(FCCTL0,(FCCTL0_BUSOFF_MASK_MASK)); /* Enable interrupts */
>
> }
>
> To test the transmission i put on MB2 registers the data and i give the tx code on FCMB control.
>
> setReg(FCMB2_Control, 0x0080);
>
> setReg(FCMB2_ID_HIGH, 0);
> setReg(FCMB2_DATA0, 0x0000);
> setReg(FCMB2_DATA1, 0xFFFF);
> setReg(FCMB2_DATA2, 0x0000);
> setReg(FCMB2_DATA3, 0xFFFF);
> setReg(FCMB2_Control, 0x00C8);
>
> I check with the oscilloscope and i see the transmission but the device
> continue the transmission continuously ,and i'm not able to see the interrupt of succesfull transmission.
> There is someone who can give me a hand solving this problem or giving me some suggestion?
>
> Cheers
> SIMONE BENATTI
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>