Part Number:TMS320F280049Other Parts Discussed in Thread:C2000WARE
你好!我在配置F280049芯片DCAN发送时,遇到以下配置问题不是很理解?
HWREG_BP(base + CAN_O_IF1CMD) = CAN_IF1CMD_DIR;其中base = CANB_BASE ,#define CAN_IF1CMD_DIR 0x800000 // Write/Read Direction;现在的问题是:1)HWREG_BP(base + CAN_O_IF1CMD) = CAN_IF1CMD_DIR 这条句的作用是什么?2) #define CAN_IF1CMD_DIR 0x800000 // Write/Read Direction;这个注释如何理解方向是读还是写?3)如果我用寄存器来配置,其它配置不变,就单独用寄存器来替换这条语句(HWREG_BP(base + CAN_O_IF1CMD) = CAN_IF1CMD_DIR;)该如何用寄存器来写这条语句?谢谢
以下是我用寄存器来替换这条语句HWREG_BP(base + CAN_O_IF1CMD) = CAN_IF1CMD_DIR;,经过测试,发现发送失败,如果换上这条语句就能发送成功,请帮忙分一下谢谢!
//*************************通过寄存器配置代码替换HWREG_BP(base + CAN_O_IF1CMD) = CAN_IF1CMD_DIR;如下*****************************************************
while(CanbRegs.CAN_IF1CMD.bit.Busy)
{
;
}
CanbRegs.CAN_IF1ARB.bit.Dir = 1; //发送
CanbRegs.CanbRegs.CAN_IF1CMD.bit.DIR = 1;//write
//*************************通过寄存器配置代码替换HWREG_BP(base + CAN_O_IF1CMD) = CAN_IF1CMD_DIR;如下***************************************************** //while(CanbRegs.CAN_IF1CMD.bit.Busy) { ; } CanbRegs.CAN_IF1ARB.bit.Dir = 1;//发送 CanbRegs.CanbRegs.CAN_IF1CMD.bit.DIR = 1;//write
Susan Yang:
Fu Mo 说:1)HWREG_BP(base + CAN_O_IF1CMD) = CAN_IF1CMD_DIR 这条句的作用是什么?
这个是配置Write/Read Direction
#define CAN_IF1CMD_DIR 0x800000 // Write/Read Direction
您需要对照寄存器说明来看
Fu Mo 说:3)如果我用寄存器来配置,其它配置不变,就单独用寄存器来替换这条语句(HWREG_BP(base + CAN_O_IF1CMD) = CAN_IF1CMD_DIR;)该如何用寄存器来写这条语句?
建议您看一下28377D的can例程,两者均是使用的DCAN
C2000Ware\device_support\f2837xd\examples\cpu1\can_external_transmit
,
Fu Mo:
谢谢!看了手册也明白了HWREG_BP(base + CAN_O_IF1CMD) = CAN_IF1CMD_DIR;这条语句是表示将数据从IF寄存器传到邮箱,跟我用寄存配置CanbRegs.CanbRegs.CAN_IF1CMD.bit.DIR = 1;是一样的。但是我用这条语句CanbRegs.CanbRegs.CAN_IF1CMD.bit.DIR = 1;替换掉HWREG_BP(base + CAN_O_IF1CMD) = CAN_IF1CMD_DIR;这条语句为什么就发送不了数据呢?其它程序都不改变,只是替换这条语句。28377D的例程序也不全是寄存器配置,这部分好像也没有。希望帮忙解决以上问题。谢谢!
,
Susan Yang:
Fu Mo 说:但是我用这条语句CanbRegs.CanbRegs.CAN_IF1CMD.bit.DIR = 1;替换掉HWREG_BP(base + CAN_O_IF1CMD) = CAN_IF1CMD_DIR;这条语句为什么就发送不了数据呢?
请问您使用的是哪个版本的C2000ware呢?我在最新的C2000ware版本内没有找到该语句
具体您可以看一下之前工程师的说明
https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/615621/ccs-tms320f280049m-issue-about-can
,
Fu Mo:
好的,谢谢!问题已经得到解决~
,
Susan Yang:
很高兴您能解决问题