EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

msCAN Transmit problem

Started by Doug Brainard September 19, 2002
I am having a problem setting the Transmit ID buffers in my CAN
setup. I am using the following code section:

CAN0TIDR0 = tran.id[0];
CAN0TIDR1 = tran.id[1];
CAN0TIDR2 = tran.id[2];
CAN0TIDR3 = tran.id[3];

Seems simple enough. This in turn compiles into this assembly code:

movb 1000, 170
movb 1001, 171
movb 1002, 172
movb 1003, 173

However, when I step through this code, it acts like nothing has
happened. I can transmit packets properly, but I seem to have no
control as to what I am sending out. Do I need to set a register
somewhere to allow CAN registers to act as normal ones? Does the
CAN0 transmit ID start at address 170 like I believe? Those are the
two possible problems that I have thought of. I have attached my
CAN initialization code as well below. Any help would be greatly
appreciated. Thank you.
Doug

// Set Up Function for the CAN Controller
void CAN_Setup(void)
{
CAN0CTL1 = 0x80; // normal operation,
oscillator clock
CAN0BTR0 = 0xC0; // SJW = 4, BRP = 1, 4mhz
// for 24mhz CAN0BTR0 = 0xC5; // SJW = 4, BRP = 6
CAN0BTR1 = 0x49; // 1 sample, TS1 = 10, TS2 =
5

CAN0IDAR0 = 0x67;
CAN0IDAR1 = 0x8A; // filter id = 0x0CF0xxxx
CAN0IDAR2 = 0x00;
CAN0IDAR3 = 0x00; // filter id = 0x0000xxxx
CAN0IDAR4 = 0x00;
CAN0IDAR5 = 0x00; // filter id = 0x0000xxxx
CAN0IDAR6 = 0x00;
CAN0IDAR7 = 0x00; // filter id = 0x0000xxxx

CAN0IDMR0 = 0x00;
CAN0IDMR1 = 0x00; // check every bit in filter
CAN0IDMR2 = 0x00;
CAN0IDMR3 = 0x00; // check every bit in filter
CAN0IDMR4 = 0x00;
CAN0IDMR5 = 0x00; // check every bit in filter
CAN0IDMR6 = 0x00;
CAN0IDMR7 = 0x00; // check every bit in filter

CAN0CTL0 &= ~(0x01); // normal mode
CAN0RFLG = 0xFF; // clear all CAN error flags
CAN0RIER = 0x01; // receive interrupt enable

// Synchronization Loop
while (!(CAN0CTL0 & 0x10)); // wait for bus
synchronization
}



Hi Doug,

CAN address 170 is the 3rd Tx buffer, is that the same one that
you are transmitting data from? Is it possible that you are setting
the data in one transmit buffer and transmitting a different one?

Steve

Zanthic Technologies Inc. is located at www.zanthic.com
Your Controller Area Networking Experts!
Embedded micro-controllers and CAN interface devices sold here

----- Original Message -----
From: Doug Brainard
To:
Sent: Thursday, September 19, 2002 4:24 PM
Subject: [68HC12] msCAN Transmit problem I am having a problem setting the Transmit ID buffers in my CAN
setup. I am using the following code section:

CAN0TIDR0 = tran.id[0];
CAN0TIDR1 = tran.id[1];
CAN0TIDR2 = tran.id[2];
CAN0TIDR3 = tran.id[3];

Seems simple enough. This in turn compiles into this assembly code:

movb 1000, 170
movb 1001, 171
movb 1002, 172
movb 1003, 173

However, when I step through this code, it acts like nothing has
happened. I can transmit packets properly, but I seem to have no
control as to what I am sending out. Do I need to set a register
somewhere to allow CAN registers to act as normal ones? Does the
CAN0 transmit ID start at address 170 like I believe? Those are the
two possible problems that I have thought of. I have attached my
CAN initialization code as well below. Any help would be greatly
appreciated. Thank you.
Doug

// Set Up Function for the CAN Controller
void CAN_Setup(void)
{
CAN0CTL1 = 0x80; // normal operation,
oscillator clock
CAN0BTR0 = 0xC0; // SJW = 4, BRP = 1, 4mhz
// for 24mhz CAN0BTR0 = 0xC5; // SJW = 4, BRP = 6
CAN0BTR1 = 0x49; // 1 sample, TS1 = 10, TS2 =
5

CAN0IDAR0 = 0x67;
CAN0IDAR1 = 0x8A; // filter id = 0x0CF0xxxx
CAN0IDAR2 = 0x00;
CAN0IDAR3 = 0x00; // filter id = 0x0000xxxx
CAN0IDAR4 = 0x00;
CAN0IDAR5 = 0x00; // filter id = 0x0000xxxx
CAN0IDAR6 = 0x00;
CAN0IDAR7 = 0x00; // filter id = 0x0000xxxx

CAN0IDMR0 = 0x00;
CAN0IDMR1 = 0x00; // check every bit in filter
CAN0IDMR2 = 0x00;
CAN0IDMR3 = 0x00; // check every bit in filter
CAN0IDMR4 = 0x00;
CAN0IDMR5 = 0x00; // check every bit in filter
CAN0IDMR6 = 0x00;
CAN0IDMR7 = 0x00; // check every bit in filter

CAN0CTL0 &= ~(0x01); // normal mode
CAN0RFLG = 0xFF; // clear all CAN error flags
CAN0RIER = 0x01; // receive interrupt enable

// Synchronization Loop
while (!(CAN0CTL0 & 0x10)); // wait for bus
synchronization
}

--------------------
">http://docs.yahoo.com/info/terms/


For 1 you are not setting the message length
Dale Kelley

-----Original Message-----
From: Doug Brainard [mailto:]
Sent: Thursday, September 19, 2002 6:24 PM
To:
Subject: [68HC12] msCAN Transmit problem I am having a problem setting the Transmit ID buffers in my CAN
setup. I am using the following code section:

CAN0TIDR0 = tran.id[0];
CAN0TIDR1 = tran.id[1];
CAN0TIDR2 = tran.id[2];
CAN0TIDR3 = tran.id[3];

Seems simple enough. This in turn compiles into this assembly code:

movb 1000, 170
movb 1001, 171
movb 1002, 172
movb 1003, 173

However, when I step through this code, it acts like nothing has
happened. I can transmit packets properly, but I seem to have no
control as to what I am sending out. Do I need to set a register
somewhere to allow CAN registers to act as normal ones? Does the
CAN0 transmit ID start at address 170 like I believe? Those are the
two possible problems that I have thought of. I have attached my
CAN initialization code as well below. Any help would be greatly
appreciated. Thank you.
Doug

// Set Up Function for the CAN Controller
void CAN_Setup(void)
{
CAN0CTL1 = 0x80; // normal operation,
oscillator clock
CAN0BTR0 = 0xC0; // SJW = 4, BRP = 1, 4mhz
// for 24mhz CAN0BTR0 = 0xC5; // SJW = 4, BRP = 6
CAN0BTR1 = 0x49; // 1 sample, TS1 = 10, TS2 =
5

CAN0IDAR0 = 0x67;
CAN0IDAR1 = 0x8A; // filter id = 0x0CF0xxxx
CAN0IDAR2 = 0x00;
CAN0IDAR3 = 0x00; // filter id = 0x0000xxxx
CAN0IDAR4 = 0x00;
CAN0IDAR5 = 0x00; // filter id = 0x0000xxxx
CAN0IDAR6 = 0x00;
CAN0IDAR7 = 0x00; // filter id = 0x0000xxxx

CAN0IDMR0 = 0x00;
CAN0IDMR1 = 0x00; // check every bit in filter
CAN0IDMR2 = 0x00;
CAN0IDMR3 = 0x00; // check every bit in filter
CAN0IDMR4 = 0x00;
CAN0IDMR5 = 0x00; // check every bit in filter
CAN0IDMR6 = 0x00;
CAN0IDMR7 = 0x00; // check every bit in filter

CAN0CTL0 &= ~(0x01); // normal mode
CAN0RFLG = 0xFF; // clear all CAN error flags
CAN0RIER = 0x01; // receive interrupt enable

// Synchronization Loop
while (!(CAN0CTL0 & 0x10)); // wait for bus
synchronization
}

--------------------
">http://docs.yahoo.com/info/terms/ ------------------------
This message is for the designated recipient only and may
contain privileged, proprietary, or otherwise private information.
If you have received it in error, please notify the sender
immediately and delete the original. Any unauthorized use of
this email is prohibited.
------------------------



The 2024 Embedded Online Conference