cancel
Showing results for 
Search instead for 
Did you mean: 

can over run

alireza_roozitalab
Associate III
Posted on July 18, 2015 at 19:02

i using stm23f429 as can controller for servo drive

but some time i have over run problem. i check the signals by oscope and understood that , some time fifo of canbx dose not being empty even a can massage transmit correctly and respond is recieved

please see attached pic

d1-> can_rx

d0->can_tx

1->canh

2->canl

for example in the pic i need send just one massage to node id 0x620 but i send three massage as the same correctly

0690X0000060MnCQAU.gif

0690X0000060MnDQAU.gif

7 REPLIES 7
jpeacock
Associate II
Posted on July 20, 2015 at 15:19

Not much information so I'd suggest you look at why the transmitter node is sending three messages back to back.  This looks like a software problem.  How are you managing the TX mailboxes?

If you are using interrupts the receiver node should not overflow.

  Jack Peacock

alireza_roozitalab
Associate III
Posted on July 21, 2015 at 20:41

thanks for your replay

i didnot use can tx irq my config code:

CAN_DeInit(CAN1);
CAN_StructInit(&CAN_InitStructure);
/* CAN cell init */
CAN_InitStructure.CAN_TTCM = DISABLE;
CAN_InitStructure.CAN_ABOM = DISABLE;
CAN_InitStructure.CAN_AWUM = DISABLE;
CAN_InitStructure.CAN_NART = DISABLE;
CAN_InitStructure.CAN_RFLM = DISABLE;
CAN_InitStructure.CAN_TXFP = DISABLE;
CAN_InitStructure.CAN_Mode = CAN_Mode_Normal;
CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;
/* CAN Baudrate = 1MBps (45/3)/(6+8+1) */
CAN_InitStructure.CAN_BS1 = CAN_BS1_8tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_6tq;
CAN_InitStructure.CAN_Prescaler = 3;
CAN_Init(CAN1, &CAN_InitStructure);
/* CAN filter init */
CAN_FilterInitStructure.CAN_FilterNumber = 0;
CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask;
CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit;
CAN_FilterInitStructure.CAN_FilterIdHigh = 0x0000;
CAN_FilterInitStructure.CAN_FilterIdLow = 0x0000;
CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x0000;
CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x0000;
CAN_FilterInitStructure.CAN_FilterFIFOAssignment = 0;
CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;
CAN_FilterInit(&CAN_FilterInitStructure);

and send process is:

TxMessage.StdId=addr;
TxMessage.RTR=CAN_RTR_DATA;
TxMessage.IDE=CAN_ID_STD;
TxMessage.DLC=8;
TxMessage.Data[0]=command;
TxMessage.Data[1]=(index & 0x00ff);
TxMessage.Data[2]=((index & 0xff00)>>0x8);
TxMessage.Data[3]=subindex;
TxMessage.Data[4]=((data & 0x000000ff));
TxMessage.Data[5]=((data & 0x0000ff00)>>0x8);
TxMessage.Data[6]=((data & 0x00ff0000)>>0x10);
TxMessage.Data[7]=((data & 0xff000000)>>0x18); 
a=CAN_Transmit(CAN1, &TxMessage);
while((CAN_TransmitStatus(CAN1, a) != CANTXOK));

alireza_roozitalab
Associate III
Posted on July 21, 2015 at 20:50

and i have sending over flow problem i just send on packet to node 0x620 by micro controller but three massage has been sent , and after of each sending , node respond EOF  correctly so the first packet transmitted  true . why micro continues sending?

alireza roozitalab
Posted on July 21, 2015 at 22:06

why micro continues sending?

I'm not convinced it's not a problem with your code. Your selective editing doesn't help your case. Post a complete/concise example that demonstrates this flaw. It doesn't have to be your complete application, just enough compilable code where you can show the same burst of messages, when you send just one transmission.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
alireza_roozitalab
Associate III
Posted on July 23, 2015 at 18:50 for example this simple code:

#define write 0x600
void can1_init()
{
GPIO_InitTypeDef GPIO_InitStructure;
CAN_InitTypeDef CAN_InitStructure;
CAN_FilterInitTypeDef CAN_FilterInitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA , ENABLE);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_CAN1);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_CAN1);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* CAN configuration */ 
/* Enable CAN clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE);
/* CAN register init */
CAN_DeInit(CAN1);
CAN_StructInit(&CAN_InitStructure);
/* CAN cell init */
CAN_InitStructure.CAN_TTCM = DISABLE;
CAN_InitStructure.CAN_ABOM = DISABLE;
CAN_InitStructure.CAN_AWUM = DISABLE;
CAN_InitStructure.CAN_NART = DISABLE;
CAN_InitStructure.CAN_RFLM = DISABLE;
CAN_InitStructure.CAN_TXFP = DISABLE;
CAN_InitStructure.CAN_Mode = CAN_Mode_Normal;
CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;
/* CAN Baudrate = 1MBps */
CAN_InitStructure.CAN_BS1 = CAN_BS1_8tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_6tq;
CAN_InitStructure.CAN_Prescaler = 3;
CAN_Init(CAN1, &CAN_InitStructure);
/* CAN filter init */
CAN_FilterInitStructure.CAN_FilterNumber = 0;
CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask;
CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit;
CAN_FilterInitStructure.CAN_FilterIdHigh = 0x0000;
CAN_FilterInitStructure.CAN_FilterIdLow = 0x0000;
CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x0000;
CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x0000;
CAN_FilterInitStructure.CAN_FilterFIFOAssignment = 0;
CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;
CAN_FilterInit(&CAN_FilterInitStructure);
}
void Can_Writeindex(uint16_t addr,uint8_t command,uint16_t index,uint8_t subindex,uint32_t data)
{
uint8_t a;
CanTxMsg TxMessage;
addr=write|addr;
a=0;
TxMessage.StdId=addr;
TxMessage.RTR=CAN_RTR_DATA;
TxMessage.IDE=CAN_ID_STD;
TxMessage.DLC=8;
TxMessage.Data[0]=command;
TxMessage.Data[1]=(index & 0x00ff);
TxMessage.Data[2]=((index & 0xff00)>>0x8);
TxMessage.Data[3]=subindex;
TxMessage.Data[4]=((data & 0x000000ff));
TxMessage.Data[5]=((data & 0x0000ff00)>>0x8);
TxMessage.Data[6]=((data & 0x00ff0000)>>0x10);
TxMessage.Data[7]=((data & 0xff000000)>>0x18); 
a=CAN_Transmit(CAN1, &TxMessage);
while((CAN_TransmitStatus(CAN1, a) != CANTXOK));
}
uint8_t Can_waitforwite()
{
CanRxMsg RxMessage;
while((CAN_MessagePending(CAN1, CAN_FIFO0) < 1)); 
CAN_Receive(CAN1, CAN_FIFO0, &RxMessage);
if (RxMessage.Data[0]==0x60)
{
return 1;
}
else
return 0; 
}

int main(void)
{
can1_init();
while(1){
Can_Writeindex(0x20,0x23,0x60FF,0,0xffff);
Canopen_waitforwite();
delay();
}}

jpeacock
Associate II
Posted on July 23, 2015 at 19:19

After a quick look at your code there is a path that will cause it to send multiple times.  If there is already a message in the RX FIFO then your loop that does a send-receive will be out of sync, causing a TX message flood. 

Make sure the RX FIFO is empty before each CAN transmit.  This assumes your other node isn't sending other messages.

  Jack Peacock
Posted on July 23, 2015 at 19:24

Try this, it will make for a more effective demonstration

int main(void)
{
uint32_t data = 0; 
can1_init();
while(1)
{
if (data == 0)
data = 1; 
Can_Writeindex(0x20,0x23,0x60FF,0,data);
data <<= 1;
Canopen_waitforwite();
delay(); 
}
}

Do you get any errors from the functions? Does the receiver acknowledge the three packets?
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..