S12G CAN

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S12G CAN

618 Views
DustyStew
Contributor V

I'm working with the S12G128 and S12GA240. By and large I have found these chips to be better documented and easier to work with than Kinetis. If you're look for a good replacement for an 8 bit processor, these are nice chips.

 

Anyway --- I've got a little problem. I've not worked with CAN before. I wrote a CAN driver in C for the GA MCU, and that was very easy to do and has run perfectly.

I am now using the same code with the G128, on more-or-less the same hardware (ie NXP driver chip).

I'm sending what should be the same message as I am with the GA. Same ID and so on.

 

But on the G128, it just keeps on sending...ad infinitum. I have scoped CanRx/Tx, and CANH and CANL. It looks good. The CanRx and CanTx are exactly the same from what I can see.

There is nothing else connected to the bus, but for a CAN monitoring device, and that monitoring device works with the GA MCU. I suppose it could be some other aspect of my code, that is tromping on memory, or something, because while the driver is the same, the rest of the code is not all the same. The G128 is using a lot more memory.

 

Unfortunately my understanding of CAN is weak, and I don't know MSCAN too well either. I am wondering what the conditions are that would cause MSCAN to keep sending.

 

If the signal on CANRX and CANTX are the same, should that not satisfy MSCAN that its tranmission was successful?

Could this problem be caused by a filter setting?

Does the peripheral have the built-in smarts to stop? Or do I need to monitor the error count and kill it?

Labels (1)
0 Kudos
1 Reply

362 Views
DustyStew
Contributor V

Answering my own question. The clue was that my CANbus monitor device does exactly the same thing. It was simply a bus wiring error, but the transmitter keeps transmitting "forever" under such an error condition.

The bus driver chip is a TJA1051 from NXP.

If I turn my device's power off on my board, the CANbus monitor will transmit forever (the software indicating there are bus errors).

If I turn my device's power on, but hold the MCU in reset, the CANbus monitor does the same.

So it seems as if the CANbus monitor is looking for some kind of acknowledge.

I'm afraid I am too green with regard to CAN. I thought it was simply a broadcast protocol where no acknowledge was required, the sender just wanted to see that their message was duplicated on the bus exactly as they sent it. Because otherwise a bus collision had occurred (or higher priority device as taking the bus).

On another note, is it possible to make MSCAN into a receive-only node? I have tried this, with no CANTX line connection, just CANRX. Then set the "listen only"
bit. It doesn't work. As you would expect from the above, without the CANTX line driven back, the other device is not happy. It does work if there is a second device on the bus, and as this happens to be what I am doing, I can live with it for the time being.

Anyway -- it is working now, I have two S12G's, one is connected to CAN Rx/Tx, the other with Rx only connected and "Listen only" bit set.

0 Kudos