Transmit FlexCAN S32K148

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Transmit FlexCAN S32K148

1,020 次查看
faress_mansouri
Contributor II

How can i transmit a table of int8_t elements without using any SDK ?

Example : i want to send a table (8bytes) in this forme :Int8_t tab[] = {1,2,3,4,5,6,7,8}

what should i put in my MBs payload fields ?

CAN0->RAMn[ 0*MSG_BUF_SIZE + 2] = ???? /* MB0 word 2: data word 0 */
CAN0->RAMn[ 0*MSG_BUF_SIZE + 3] = ???? /* MB0 word 3: data word 1 */


CAN0->RAMn[ 0*MSG_BUF_SIZE + 1] = ID /* MB0 word 1: Tx msg with STD ID 0x511 */
CAN0->RAMn[ 0*MSG_BUF_SIZE + 0] = configuration /* MB0 word 0: */

 

标记 (1)
2 回复数

915 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

upi can use


CAN0->RAMn[ 0*MSG_BUF_SIZE + 2] = tab[0]<<24|tab[1]<<16|tab[2]<<8|tab[3];
CAN0->RAMn[ 0*MSG_BUF_SIZE + 3] = tab[4]<<24|tab[5]<<16|tab[6]<<8|tab[7]; 

or with the help of pointer

uint8_t i,j,*pMB;
pMB = &CAN0->RAMn[ 0*MSG_BUF_SIZE + 2];
for(j=0;j<2;j++)
    for(i=0;i<4;i++) *pMB++ = tab[4*j+3-i];

BR, Petr

915 次查看
faress_mansouri
Contributor II

Thanks for your help 

0 项奖励
回复