FlexCAN

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

FlexCAN

2,629件の閲覧回数
Nerone
Contributor I
I am a newbie with the flexCAN. I have two 56f8300DEMO boards and I want experiment connect them with CAN. I've not freescaleCAN bean licensed so I need for a very simple example code for tx and rx tasks. I tried to develop my own code, but only tx work, no rx.

I appreciate some help to me.

thanks in advance
0 件の賞賛
返信
2 返答(返信)

818件の閲覧回数
admin
Specialist II
Code:
volatile word* data_base = &FCMB0_DATA0;volatile word* control_base = &FCMB0_Control;volatile word* data_reg;volatile word* control_reg;#define reg_offs 0x8...void Readbuff(byte numbuf, byte* data){   byte i, RxCode, length;      data_reg = data_base + numbuf*reg_offs;   control_reg = control_base + numbuf*reg_offs;         RxCode = (*control_reg & 0xF0)>>4;  /* read RxCode */     *control_reg = (*control_reg & 0xFF0F); /* hold inactive Rx buffer */   length = (byte)(*control_reg & 0x0F); /* length of the received message */   for (i=0; i<length/2; i++)   {      *data++ = (byte)(*data_reg >> 8);      *data++ = (byte)(*data_reg);   }   if (length & 1)   *data = (byte)(*data_reg);  *control_reg = 0x40; /* set the message buffer code = Empty*/}....// CAN Tx-Rx interrupt function#pragma interrupt alignsp saveallvoid CANInterrupt(void){   byte rxBuff[8];      word BufFlags = getReg(FCIFLAG1);   setReg(FCIFLAG1,BufFlags);  /* clear interrupt flags */   if ((BufFlags & 0x02) > 0)  /* MB1 transmit */   {//  after transmition action code here   }   if ((BufFlags & 0x01) > 0)  /* MB0 receive */   {      Readbuff(0,rxBuff);//  another receive action code here   }}

 
Try this code. This is simple example of read of the received DATA frame from CAN buffer 0.
 

Message Edited by Alexey on 2006-12-2312:32 PM

0 件の賞賛
返信

818件の閲覧回数
Nerone
Contributor I
Thanks you!
0 件の賞賛
返信