cancel
Showing results for 
Search instead for 
Did you mean: 

A question about STR710 can

ys03241028
Associate II
Posted on May 26, 2005 at 07:41

A question about STR710 can

3 REPLIES 3
ys03241028
Associate II
Posted on May 26, 2005 at 01:55

Hi,I have a question about st710 CAN

When i transmit data between two ST710 Can controller,both them are configured by following code:

void config_CAN(void)

{

u16 uMask;

RCCU->CCR = 0x00;

While (RCCU->CCR != 0x00) RCCU->CCR = 0x00;

RCCU->CFR = 0x8008;

While (RCCU->CFR != 0x8008) RCCU->CFR = 0x8008;

PCU->MDIVR = 0x00;

PCU->PDIVR = 0x00;

// setup GPIO 1.11 (CAN RX pin) as input Tristate CMOS

uMask = 1<

GPIO1->PC0 &=~uMask;

GPIO1->PC1 |= uMask;

GPIO1->PC2 &=~uMask;

// setup GPIO 1.12 (CAN TX pin) as output alternate Push-pull

uMask = 1<

GPIO1->PC0 |= uMask;

GPIO1->PC1 |= uMask;

GPIO1->PC2 |= uMask;

CAN_Init(0, CAN_BITRATE_250K); // ST710 lib function

CAN_InvalidateAllMsgObj(); // ST710 lib function

}

Note that: CAN_BITRATE_250K set can BTR as : Tseg1(4),Tseg2(3), SJW (3), BRP (4)

and Main Oscillator Frequency value is 16 Mhz.

Both transmitter and receiver use standard id.

transmitter's and receiver's code are following:

canmsg TxCanMsg[2] = {

{ CAN_STD_ID, 0x123, 4, { 0x01, 0x02, 0x04, 0x08 } },

{ CAN_EXT_ID, 0x12345678, 8, { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 } }

};

while(1)

{

if((CAN->ERR & 0x8000)==0x8000)

{

CAN->ERR = 0;

CAN_Init(0, CAN_BITRATE_250K);

CAN_InvalidateAllMsgObj();

}

// configure the message objects

CAN_SetUnusedMsgObj(CAN_TX_MSGOBJ);

CAN_SetUnusedMsgObj(CAN_RX_MSGOBJ);

#if TX_RX_NODE

CAN_SetTxMsgObj(CAN_TX_MSGOBJ, CAN_STD_ID);

CAN_SetRxMsgObj(CAN_RX_MSGOBJ, CAN_STD_ID, 0, CAN_LAST_STD_ID, TRUE);

// send a pre-defined data frame

(void)CAN_SendMessage(CAN_TX_MSGOBJ, &TxCanMsg[0]);

// wait until end of transmission

CAN_WaitEndOfTx();

// release the message objects

CAN_ReleaseTxMessage(CAN_TX_MSGOBJ);

#else

Wait();//delay 5ms

if(CAN_ReceiveMessage(CAN_RX_MSGOBJ, FALSE, &RxCanMsg)==1)

{

CAN_ReleaseRxMessage(CAN_RX_MSGOBJ);

}

#endif

Wait();// delay 5ms

}

I always got error in transmitter:

'' Bit1Error: During the transmission of a message (with the exception of the arbitration field),

the device wanted to send a recessive level (bit of logical value ‘1’),

but the monitored bus value was dominant. ''

and receiver's error is:

''Form Error: A fixed format part of a received frame has the wrong format.''

[ This message was edited by: windsea on 26-05-2005 05:31 ]

davidbellegarde9
Associate II
Posted on May 26, 2005 at 07:16

I tried to communicate with 2 STR710 and it works.

I used 2 different code, there is one transmitter/receiver and the other one is the receiver/transmitter.

The source code of the first one is:

while(1)

{

// initialize the CAN at a standard bitrate, interrupts disabled

CAN_Init(0, CAN_BITRATE_100K);

// configure the message objects

CAN_InvalidateAllMsgObj();

CAN_SetTxMsgObj(CAN_TX_MSGOBJ, CAN_STD_ID);

CAN_SetRxMsgObj(CAN_RX_MSGOBJ, CAN_STD_ID, 0, CAN_LAST_STD_ID, TRUE);

//Initialisation OK

LED_On(0);

//Send the pre-defined frame

(void)CAN_SendMessage(CAN_TX_MSGOBJ, &TxCanMsg[0]);

// wait until end of transmission

CAN_WaitEndOfTx();

//Message Sent

LED_On(1);

// wait for reception of a data frame

while (!CAN_ReceiveMessage(CAN_RX_MSGOBJ, FALSE, &RxCanMsg))

{

//Timer

LED_Toggle(2);

}

//Test Received Msg

if((RxCanMsg.IdType == CAN_STD_ID)&&(RxCanMsg.Id == 0x123)&&(RxCanMsg.Dlc == 4)

&&(RxCanMsg.Data[0]==0x01)&&(RxCanMsg.Data[1]==0x02)&&(RxCanMsg.Data[2]==0x04)&&(RxCanMsg.Data[3]==0x08)){

//Received Msg OK

LED_On(2);

} else {

//Received Msg KO

LED_Toggle(7);

}

}

and the second one is:

while(1)

{

// initialize the CAN at a standard bitrate, interrupts disabled

CAN_Init(0, CAN_BITRATE_100K);

// configure the message objects

CAN_InvalidateAllMsgObj();

CAN_SetTxMsgObj(CAN_TX_MSGOBJ, CAN_STD_ID);

CAN_SetRxMsgObj(CAN_RX_MSGOBJ, CAN_STD_ID, 0, CAN_LAST_STD_ID, TRUE);

//Initialisation OK

LED_On(0);

// wait for reception of a data frame

while (!CAN_ReceiveMessage(CAN_RX_MSGOBJ, FALSE, &RxCanMsg))

{

//Timer

}

//Test Received Msg

if((RxCanMsg.IdType == CAN_STD_ID)&&(RxCanMsg.Id == 0x123)&&(RxCanMsg.Dlc == 4)

&&(RxCanMsg.Data[0]==0x01)&&(RxCanMsg.Data[1]==0x02)&&(RxCanMsg.Data[2]==0x04)&&(RxCanMsg.Data[3]==0x08)){

//Received Msg OK

LED_On(1);

} else {

//Received Msg KO

LED_Toggle(7);

}

//Send the pre-defined answer

(void)CAN_SendMessage(CAN_TX_MSGOBJ, &TxCanMsg[1]);

// wait until end of transmission

CAN_WaitEndOfTx();

//Message Sent

LED_On(2);

}

Regards.

ys03241028
Associate II
Posted on May 26, 2005 at 07:41

hi,squirrel

thanks for your reply!

you mean you can transmit and receive data correctly using code

above? if that so,I think maybe there is something wrong with

my can controller interface. can you tell me your can controller

interface circuit?

I used a Ti's sn65hvd230 as can controller interface.

[ This message was edited by: windsea on 26-05-2005 11:13 ]