TI中文支持网
TI专业的中文技术问题搜集分享网站

28035 can应答错误

我在调试can发送的时候一直在等待发送标志位置位,用两块板子进行调试,一收一发,发送端错误寄存器提示正在发送和应答错误,不知道什么原因,还请知道的帮忙看一下。下面是位的初始化程序

void InitECan0(void)

{  

EALLOW;

    GpioCtrlRegs.GPAPUD.bit.GPIO30 = 0;     // Enable pull-up for GPIO30 (CANRXA)

    GpioCtrlRegs.GPAPUD.bit.GPIO31 = 0;     // Enable pull-up for GPIO31 (CANTXA)

    GpioCtrlRegs.GPAQSEL2.bit.GPIO30 = 3;   // Asynch qual for GPIO30 (CANRXA)

    GpioCtrlRegs.GPAMUX2.bit.GPIO30 = 1;    // Configure GPIO30 for CANRXA operation

    GpioCtrlRegs.GPAMUX2.bit.GPIO31 = 1;    // Configure GPIO31 for CANTXA operation

    EDIS;

    EALLOW;     // EALLOW enables access to protected bits

/* Configure eCAN RX and TX pins for CAN operation using eCAN regs*/

    ECanaShadow.CANTIOC.all = ECanaRegs.CANTIOC.all;

    ECanaShadow.CANTIOC.bit.TXFUNC = 1;

    ECanaRegs.CANTIOC.all = ECanaShadow.CANTIOC.all;

    ECanaShadow.CANRIOC.all = ECanaRegs.CANRIOC.all;

    ECanaShadow.CANRIOC.bit.RXFUNC = 1;

    ECanaRegs.CANRIOC.all = ECanaShadow.CANRIOC.all;

EALLOW;

ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;

//工作在正常模式

ECanaShadow.CANMC.bit.STM = 0;

//工作在eCAN模式

ECanaShadow.CANMC.bit.SCB = 1;

ECanaShadow.CANMC.bit.ABO = 1;

ECanaShadow.CANMC.bit.SUSP = 1 ;    //为了保证在挂起的状态下仍然可以收发数据

ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;

EDIS;

//初始化所有主设备控制区域为0,控制区域所有的位都初始化为0

ECanaMboxes.MBOX0.MSGCTRL.all = 0x00000000;

    ECanaMboxes.MBOX1.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX2.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX3.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX4.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX5.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX6.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX7.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX8.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX9.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX10.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX11.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX12.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX13.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX14.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX15.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX16.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX17.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX18.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX19.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX20.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX21.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX22.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX23.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX24.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX25.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX26.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX27.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX28.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX29.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX30.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX31.MSGCTRL.all = 0x00000000;

//清除所有的TA位

ECanaRegs.CANTA.all = 0xFFFFFFFF;

//清除所有的RMP位

ECanaRegs.CANRMP.all = 0xFFFFFFFF;

//配置时钟参数

EALLOW;

ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;

ECanaShadow.CANMC.bit.CCR = 1;

ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;

EDIS;

//CPU请求向CANBTC和CANGAM写配置信息,该位置1后必须等到CANED.CCE为1,才能

//对CANBTC进行操作。

do

{

ECanaShadow.CANES.all = ECanaRegs.CANES.all;

}

while(ECanaShadow.CANES.bit.CCE != 1);

EALLOW;

//500kHz

ECanaShadow.CANBTC.bit.BRPREG = 3;

ECanaShadow.CANBTC.bit.TSEG2REG = 2;

ECanaShadow.CANBTC.bit.TSEG1REG = 10;

ECanaRegs.CANBTC.all = ECanaShadow.CANBTC.all;

    //CPU请求正常操作

ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;

ECanaShadow.CANMC.bit.CCR = 0;

ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;

EDIS;

do

{

ECanaShadow.CANES.all = ECanaRegs.CANES.all;

}

while(ECanaShadow.CANES.bit.CCE != 0); //等待CCE位清零

//屏蔽所有邮箱,在写MSGID之前要完成该操作

ECanaRegs.CANME.all = 0;

//设置发送邮箱的ID号,扩展帧

ECanaMboxes.MBOX0.MSGID.all = 0x80C80000;

//邮箱0为TX

ECanaShadow.CANMD.all = ECanaRegs.CANMD.all;

ECanaShadow.CANMD.bit.MD0 =0;

ECanaRegs.CANMD.all = ECanaShadow.CANMD.all;

//数据长度 8个BYTE

ECanaMboxes.MBOX0.MSGCTRL.bit.DLC = 8;

//设置发送优先级

ECanaMboxes.MBOX0.MSGCTRL.bit.TPL = 0;

//没有远方应答帧被请求

ECanaMboxes.MBOX0.MSGCTRL.bit.RTR = 0;

//向邮箱RAM区写数据

ECanaMboxes.MBOX0.MDL.all = 0x01234567;

ECanaMboxes.MBOX0.MDH.all = 0x89ABCDEF;

    //邮箱使能Mailbox0

ECanaShadow.CANME.all = ECanaRegs.CANME.all;

ECanaShadow.CANME.bit.ME0 =1;

ECanaRegs.CANME.all = ECanaShadow.CANME.all;

Hans Huang:

Hi  你的CAN问题解决了吗,我遇到了你同样的问题。

我在调试can发送的时候一直在等待发送标志位置位,用两块板子进行调试,一收一发,发送端错误寄存器提示正在发送和应答错误,不知道什么原因,还请知道的帮忙看一下。下面是位的初始化程序

void InitECan0(void)

{  

EALLOW;

    GpioCtrlRegs.GPAPUD.bit.GPIO30 = 0;     // Enable pull-up for GPIO30 (CANRXA)

    GpioCtrlRegs.GPAPUD.bit.GPIO31 = 0;     // Enable pull-up for GPIO31 (CANTXA)

    GpioCtrlRegs.GPAQSEL2.bit.GPIO30 = 3;   // Asynch qual for GPIO30 (CANRXA)

    GpioCtrlRegs.GPAMUX2.bit.GPIO30 = 1;    // Configure GPIO30 for CANRXA operation

    GpioCtrlRegs.GPAMUX2.bit.GPIO31 = 1;    // Configure GPIO31 for CANTXA operation

    EDIS;

    EALLOW;     // EALLOW enables access to protected bits

/* Configure eCAN RX and TX pins for CAN operation using eCAN regs*/

    ECanaShadow.CANTIOC.all = ECanaRegs.CANTIOC.all;

    ECanaShadow.CANTIOC.bit.TXFUNC = 1;

    ECanaRegs.CANTIOC.all = ECanaShadow.CANTIOC.all;

    ECanaShadow.CANRIOC.all = ECanaRegs.CANRIOC.all;

    ECanaShadow.CANRIOC.bit.RXFUNC = 1;

    ECanaRegs.CANRIOC.all = ECanaShadow.CANRIOC.all;

EALLOW;

ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;

//工作在正常模式

ECanaShadow.CANMC.bit.STM = 0;

//工作在eCAN模式

ECanaShadow.CANMC.bit.SCB = 1;

ECanaShadow.CANMC.bit.ABO = 1;

ECanaShadow.CANMC.bit.SUSP = 1 ;    //为了保证在挂起的状态下仍然可以收发数据

ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;

EDIS;

//初始化所有主设备控制区域为0,控制区域所有的位都初始化为0

ECanaMboxes.MBOX0.MSGCTRL.all = 0x00000000;

    ECanaMboxes.MBOX1.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX2.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX3.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX4.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX5.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX6.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX7.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX8.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX9.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX10.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX11.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX12.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX13.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX14.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX15.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX16.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX17.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX18.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX19.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX20.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX21.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX22.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX23.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX24.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX25.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX26.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX27.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX28.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX29.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX30.MSGCTRL.all = 0x00000000;

ECanaMboxes.MBOX31.MSGCTRL.all = 0x00000000;

//清除所有的TA位

ECanaRegs.CANTA.all = 0xFFFFFFFF;

//清除所有的RMP位

ECanaRegs.CANRMP.all = 0xFFFFFFFF;

//配置时钟参数

EALLOW;

ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;

ECanaShadow.CANMC.bit.CCR = 1;

ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;

EDIS;

//CPU请求向CANBTC和CANGAM写配置信息,该位置1后必须等到CANED.CCE为1,才能

//对CANBTC进行操作。

do

{

ECanaShadow.CANES.all = ECanaRegs.CANES.all;

}

while(ECanaShadow.CANES.bit.CCE != 1);

EALLOW;

//500kHz

ECanaShadow.CANBTC.bit.BRPREG = 3;

ECanaShadow.CANBTC.bit.TSEG2REG = 2;

ECanaShadow.CANBTC.bit.TSEG1REG = 10;

ECanaRegs.CANBTC.all = ECanaShadow.CANBTC.all;

    //CPU请求正常操作

ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;

ECanaShadow.CANMC.bit.CCR = 0;

ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;

EDIS;

do

{

ECanaShadow.CANES.all = ECanaRegs.CANES.all;

}

while(ECanaShadow.CANES.bit.CCE != 0); //等待CCE位清零

//屏蔽所有邮箱,在写MSGID之前要完成该操作

ECanaRegs.CANME.all = 0;

//设置发送邮箱的ID号,扩展帧

ECanaMboxes.MBOX0.MSGID.all = 0x80C80000;

//邮箱0为TX

ECanaShadow.CANMD.all = ECanaRegs.CANMD.all;

ECanaShadow.CANMD.bit.MD0 =0;

ECanaRegs.CANMD.all = ECanaShadow.CANMD.all;

//数据长度 8个BYTE

ECanaMboxes.MBOX0.MSGCTRL.bit.DLC = 8;

//设置发送优先级

ECanaMboxes.MBOX0.MSGCTRL.bit.TPL = 0;

//没有远方应答帧被请求

ECanaMboxes.MBOX0.MSGCTRL.bit.RTR = 0;

//向邮箱RAM区写数据

ECanaMboxes.MBOX0.MDL.all = 0x01234567;

ECanaMboxes.MBOX0.MDH.all = 0x89ABCDEF;

    //邮箱使能Mailbox0

ECanaShadow.CANME.all = ECanaRegs.CANME.all;

ECanaShadow.CANME.bit.ME0 =1;

ECanaRegs.CANME.all = ECanaShadow.CANME.all;

zhao zhaona:

您好,您的这个程序调出来了吗 ,我能参考一下整个程序吗,我还想问一些问题

赞(0)
未经允许不得转载:TI中文支持网 » 28035 can应答错误
分享到: 更多 (0)