Hello,
I’ve already 3 HCS12 T-boards with the mc9s12Dp512 chip in my possession. So switching to another chip isn’t an option.
msCAN is working now on 1 board when I use the loop back mode.
It isn’t working when I want to communicate between 2 HCS12 boards. Is it a wrong initialization for CAN0?
void SetCan0(void)
{
CAN0CTL1_CANE = 1; //enable CAN, required after reset
//----------------------------------------------------------------
CAN0CTL0_INITRQ = 1; //MSCAN in Initialization Mode.
while(!CAN0CTL1_INITAK); //The registers CANCTL1, CANBTR0, CANBTR1,
//CANIDAC, CANIDAR0-7, CANIDMR0-7 can
//only be written by the CPU when the MSCAN
//is in Initialization Mode.
//----------------------------------------------------------------
//Initialization Mode
CAN0CTL1 = 0xC0; //The MSCAN module is enabled.
//The MSCAN clock source is the Bus Clock.
//Loop Back Self Test disabled with 0xC0 and
//enabled with 0xE0
CAN0BTR0 = 0x08; //SJW 1 Tq clock cycles
//Prescaler value (8)
CAN0BTR1 = 0x14; //One sample per bit.
//Time Segment 2 = 2 Tq clock cycle
//Time Segment 1 = 5 Tq clock cycle
//For standard identifiers, only the first two (CANIDAR0/1,
//CANIDMR0/1) are applied
CAN0IDMR0 = 0b00000000;
CAN0IDMR1 = 0b00011111;
CAN0IDAR0 = 0b00100010;
CAN0IDAR1 = 0b00000000;
CAN0IDAC = 0x10; //Four 16 bit Acceptance Filters
//----------------------------------------------------------------
CAN0CTL0_INITRQ = 0; //MSCAN in Normal operation.
while(CAN0CTL1_INITAK); //following reg can only be written by the
//CPU when the MSCAN out of Initialization
//Mode.
//----------------------------------------------------------------
//Normal operation.
CAN0CTL0 = 0x00; //The module is not affected during Wait Mode.
//Disable internal MSCAN timer.
//Wake-Up disabled The MSCAN ignores traffic on CAN.
//Running The MSCAN functions normally.
CAN0RIER = 0x01; //A receive buffer full (successful message
//reception) event causes a receiver interrupt
//request.
CAN0TBSEL = 0x01; //TX0 message Buffer is selected, if lowest
//numbered bit.
}
greetings dan23