This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TCAN4550: TCAN4550 SPI operation goes to wrong state

Part Number: TCAN4550

Hello

I'm using  TCAN4550EVM to my board by wired connection.

and I'm trying make FW with Linux Driver code (starting with lastest version.. 5.12.xxx).

my board don't use Linux, but I can't find other driver source code.

anyway,  It works noramlly, but some times SPI bus go to wrong state.

According to Linux code, first time I set MO to normal.

After set, this value don't changed in my code.

h0800 : 0xc8004a8

I want to control CAN bus start / stop manually.

when stop state, I hope to CAN bus just ignore all signal. (don't react or reconized)

I hope to CAN bus start with new comming packet ater start condition.

I made my FW source like Linux code flow -  m_can_start() / m_can_stop()

static void m_can_start(struct net_device *dev)
{
	struct m_can_classdev *cdev = netdev_priv(dev);

	/* basic m_can configuration */
	m_can_chip_config(dev);

	cdev->can.state = CAN_STATE_ERROR_ACTIVE;

	m_can_enable_all_interrupts(cdev);
}

static void m_can_stop(struct net_device *dev)
{
	struct m_can_classdev *cdev = netdev_priv(dev);

	/* disable interrupts */
	m_can_write(cdev, M_CAN_IR, IR_ALL_INT);
	m_can_write(cdev, M_CAN_IE, 0);

	/* disable all interrupts */
	m_can_disable_all_interrupts(cdev);

	/* Set init mode to disengage from the network */
	m_can_config_endisable(cdev, true);

	/* set the state as STOPPED */
	cdev->can.state = CAN_STATE_STOPPED;
}

Start time TCAN register controled like this( m_can_start() function code)

i don't descript about M_CAN FIFO clear operation

R 0x1018 val:0x00000303
W 0x1018 val:0x00000303
W 0x1018 val:0x00000303
R 0x1018 val:0x00000303
W 0x10bc val:0x00000777
W 0x1080 val:0x00000000
W 0x10c0 val:0x01000488
W 0x10c8 val:0x00000007
W 0x10f0 val:0x00010480
W 0x10a0 val:0x00100000
W 0x10b0 val:0x00000480
R 0x1018 val:0x00000303
R 0x1010 val:0x00000080
W 0x1018 val:0x00000303
W 0x1010 val:0x00000080
W 0x000c val:0xffffffff
W 0x0824 val:0xffffffff
W 0x0820 val:0xffffffff
W 0x0010 val:0xffffffff
W 0x1050 val:0xdfffffff
W 0x1054 val:0xe7ffffff
W 0x1058 val:0x00000000
W 0x101c val:0x00003a13
W 0x100c val:0x00000e30
R 0x1018 val:0x00000303
W 0x1018 val:0x00000300
R 0x1018 val:0x00000300
W 0x105c val:0x00000001

stop state run like this (m_can_stop() function code)

W 0x1050 val:0xffffffff
W 0x1054 val:0x00000000
W 0x105c val:0x00000000
R 0x1018 val:0x00000300
W 0x1018 val:0x00000301
W 0x1018 val:0x00000303
R 0x1018 val:0x00000303

Normally, it works well in the start state.

But, if stop state, if there are packet present in CAN bus,

TCAN holds this packet, occure interupt signal after Start state.

That time, SPI bus goto some thing wrong state.

If i read reg, i can't read it right at first.

ater read twice, register value read correct.

this is normal interupt handle flow

R 0x1050 val:0x00000001
W 0x1050 val:0x00000001
W 0x000c val:0xffffffff
W 0x0824 val:0xffffffff
W 0x0820 val:0xffffffff
W 0x0010 val:0xffffffff
W 0x105c val:0x00000000
R 0x1050 val:0x00000000
R 0x1044 val:0x00000748
R 0x10a4 val:0x00010001
W 0x10a8 val:0x00000000
R 0x10a4 val:0x00010100
W 0x105c val:0x00000001

this is wrong SPI state

R 0x1050 val:0x00000000   // can't read first time
R 0x1050 val:0x00000000
R 0x1050 val:0x2100000d   // read corectly but other flags occured
W 0x1050 val:0x2100000d
W 0x000c val:0xffffffff
W 0x0824 val:0xffffffff
W 0x0820 val:0xffffffff
W 0x0010 val:0xffffffff
W 0x105c val:0x00000000
R 0x1050 val:0x00000000
R 0x1044 val:0x00000008
R 0x10a4 val:0x00000710
W 0x10a8 val:0x00000007
R 0x10a4 val:0x00000000
W 0x105c val:0x00000001

after that, I try to register manually, I have to read twice.

I think It seems like SPI bus didn't works 4byte width. lt looks like 2byte width.

I checked SPI read command signal with oscillosope, It sent correct command signal

Q1 Is there a possibility of this happening? or Is this my mis control?

Q2 I hope to CAN bus ignore all when stop state.

      should I control TCAN operating mode to stand by?

Q3. Is there any other driver sample about TCAN4550 (not Linux code)?

Thank you