Hi,
I am a new user for freescale developpement, i have a kit DEMO9S12XEP100 and i want to send a frame by my borad
So i write this code in code warrior IDE version 5.9.0
void main(void) {
MCU_init(); /* call Device Initialization */
CANInit(); /* Initialize MSCAN12 Module */
while(!(CAN0CTL0&0x10)); /* Wait for Synchronization */
CAN0RFLG = 0xC3;
CAN0RIER = 0x01;
for(; {
CAN0TBSEL = CAN0TFLG;
CAN0TXIDR0 = 0x20;
CAN0TXIDR1 = 0x00;
CAN0TXIDR2 = 0x00;
CAN0TXIDR3 = 0x00;
CAN0TXDSR0 = 0x0F;
CAN0TXDSR1 = 0x12;
CAN0TXDSR2 = 0x13;
CAN0TXDSR3 = 0x14;
CAN0TXDSR4 = 0x15;
CAN0TXDSR5 = 0x16;
CAN0TXDSR6 = 0x17;
CAN0TXDSR7 = 0x18;
CAN0TXDLR= 0x08;
CAN0TXTBPR=0x00;
/* schedule transmit buffer for transmission */
CAN0TFLG =CAN0TBSEL;
}
}
void CANInit(void) {
CAN0CTL0 = 0x01; /* Enter initialisation Mode*/
while (!(CAN0CTL1&0x01)){}; /* attente d'initialisation */
CAN0CTL1= 0x80;
CAN0BTR0= 0xC0;
CAN0BTR1= 0x3A;
CAN0IDAC= 0x10;
CAN0IDAR0= 0xFF;
CAN0IDMR0= 0xFF;
CAN0IDAR1= 0xFF;
CAN0IDMR1= 0xFF;
CAN0IDAR2= 0xFF;
CAN0IDMR2= 0xFF;
CAN0IDAR3= 0xFF;
CAN0IDMR3= 0xFF;
CAN0CTL0 = 0x00; /* Exit Initialization Mode Request */
while ((CAN0CTL1&0x01) != 0){};
}
my transeiver is TJA 1041 high speed and its conected with port S (STB and EN ) wich i configured at output and "1".
for the acknowledge, i use the CanAlyser from vector.
and when i run i obserevd in my trace in CanAlyser the erro frame.
I do not wehre is the probleme?
Thank you for my help if you are a solution for me ?
已解决! 转到解答。
Yes,
you are rignt in my program there is an error about my configuration timing
i tested and it s good about 125Kbit and i have a frame in my trace with Canalyser which its configured also at 125kbits (good)
the eroor is CAN0BTR0= 0xC1; and not 0xC0.
its necessary to configured the port ao TJA 1041T inpaut EN an STB to "1"
I will buy a oscillater with 16Mhz to make 500 Kbits/s
Yes,
you are rignt in my program there is an error about my configuration timing
i tested and it s good about 125Kbit and i have a frame in my trace with Canalyser which its configured also at 125kbits (good)
the eroor is CAN0BTR0= 0xC1; and not 0xC0.
its necessary to configured the port ao TJA 1041T inpaut EN an STB to "1"
I will buy a oscillater with 16Mhz to make 500 Kbits/s