Hello, I'm trying to send CAN messages from a TRK-S12ZVH128 to USB-CAN device, using the MSCAN and CANPHY component in processor expert .
I am able to receive or loop mode self-test, however, when I try to transmit to USB-CAN device, I send one message then the processor keeps send repeatedly.
I check following register when transmitter failure:
CAN0RFLG = 0X08,(TSTAT[1:0] = 10 or 01)
CAN0TFLG = 0X06,(TX buffer 0 is full)
And in the IRQ of CAN bus error,
void CAN1_OnError(void)
{
/* Write your code here ... */
CAN1_TError error;
CAN1_GetError(&error);
}
the error indicate TxWarning = 1
then I set the MODRR0 = 0x04,
I can find the frame on RXCAN / PC2 and the ACK on TXCAN / PC1 when USB-CAN send message to MCU.But when I send a message from MCU to USB-CAN,the bit flow on TxCAN appeared on RxCAN, without any ACK.
if I forget some configure ,or the MSCAN into LISTEN-MODE,but no happen high voltage failure.
/////////////
MSCAN configure
** Processor : MC9S12ZVH128CLQ
** Component : FreescaleCAN
** Version : Component 02.366, Driver 01.31, CPU db: 3.00.000
** Compiler : CodeWarrior HCS12Z C Compiler
** Date/Time : 2016-08-10, 15:46, # CodeGen: 5
** Abstract :
** This component "FreescaleCAN" implements a CAN serial channel.
** Settings :
** CAN channel : MSCAN0
**
** Interrupt service/event : Enabled
** Output interrupt
** Vector name : Vcan0tx
** Priority : 4
** Input interrupt
** Vector name : Vcan0rx
** Priority : 4
** Error interrupt
** Vector name : Vcan0err
** Priority : 4
** Wakeup interrupt
** Vector name : Vcan0wkup
** Priority : 4
**
** Settings :
** Rx pin : CANPHY0_RXD_to_MSCAN0_RXD
** Rx pin signal :
** Tx pin : CANPHY0_TXD_to_MSCAN0_TXD
** Tx pin Signal :
**
**
** Recieve accept. code : 0x00
** Recieve accept. mask : 0xFFFFFFFF
** Loop Mode : no
** Bus-Off Recovery : Auto
** Listen Only Mode : no
** Wakeup : Disabled
**
** Protocol
** Time segment 1 : 7
** Time segment 2 : 3
** RSJ : 1
** Samples per bit : One sample
** Time quanta per bit : 13
** Init baud rate : 100 kbit/s
**
** Initialization
** Enabled in init. code : yes
** Events enabled in init. : yes
**
** CPU clock/speed selection
** High speed mode : This component enabled
** Low speed mode : This component disabled
** Slow speed mode : This component disabled
**
** Contents :
** SetAcceptanceCode - byte CAN1_SetAcceptanceCode(dword AccCode1, dword AccCode2);
** SetAcceptanceMask - byte CAN1_SetAcceptanceMask(dword AccMask1, dword AccMask2);
** SetAcceptanceMode - byte CAN1_SetAcceptanceMode(byte Mode);
** SendFrame - byte CAN1_SendFrame(byte BufferNum, dword MessageID, byte FrameType, byte...
** ReadFrame - byte CAN1_ReadFrame(dword *MessageID, byte *FrameType, byte *FrameFormat,...
** GetStateTX - byte CAN1_GetStateTX(void);
** GetStateRX - bool CAN1_GetStateRX(void);
** GetError - byte CAN1_GetError(CAN1_TError *Err);
**
CANPHY configure
** Processor : MC9S12ZVH128CLQ
** Component : Init_CANPHY
** Version : Component 01.000, Driver 01.00, CPU db: 3.00.000
** Compiler : CodeWarrior HCS12Z C Compiler
** Date/Time : 2016-08-11, 10:36, # CodeGen: 15
** Abstract :
** This file implements the CANPHY (CANPHY0) module initialization
** according to the Peripheral Initialization settings, and
** defines interrupt service routines prototypes.
** Settings :
** Component name : CANPHY0
** Device : CANPHY0
** Settings :
** Split enable : Enabled
** Wakeup receiver : Enabled
** Physical layer slew rate : Slew rate 0
** Pins/Signals :
** Supply pin :
** Pin : VDDC
** Pin signal :
** Ground pin :
** Pin : VSSC
** Pin signal :
** CAN bus high pin :
** Pin : CANH0
** Pin signal :
** CAN bus low pin :
** Pin : CANL0
** Pin signal :
** Termination pin :
** Pin : SPLIT0
** Pin signal :
** Tx input : Enabled
** Pin : CANPHY0_TXD_to_MSCAN0_TXD
** Pin signal :
** Rx output :
** Output 0 : Enabled
** Pin : CANPHY0_RXD_to_MSCAN0_RXD
** Pin signal :
** Output 1 : Disabled
** Interrupts :
** CANPHY interrupt :
** Interrupt : Vcanphy0
** Interrupt priority : 1
** ISR Name : CANPHY0_onError
** Voltage failure Interrupt : Enabled
** Physical layer error Interrupt : Enabled
** Initialization :
** Physical layer : Enabled
** SW control value : 1
** Call Init method : yes
** Contents :
** Init - void CANPHY0_Init(void);