Things to check: That CANWRITE is really set to 1. That you are running this in the car, not on your workbench. If workbench, make sure you have at least two CAN devices in active mode on the bus, and termination resistors in place. It won’t work with just the OVMS module on its own as CAN requires at least two active nodes on the network. Example code: while (TXB0CONbits.TXREQ) {} // Loop until TX is done TXB0CON = 0; TXB0SIDL = 0b01000000; // Setup 0x102 TXB0SIDH = 0b00100000; // Setup 0x102 TXB0D0 = 0x06; TXB0D1 = 0x2c; TXB0D2 = 0x01; TXB0D3 = 0x00; TXB0D4 = 0x00; TXB0D5 = 0x09; TXB0D6 = 0x10; TXB0D7 = 0x00; TXB0DLC = 0b00001000; // data length (8) TXB0CON = 0b00001000; // mark for transmission while (TXB0CONbits.TXREQ) {} // Loop until TX is done Regards, Mark.
On 12 Jan 2016, at 6:43 AM, Michael Balzer <dexter@expeedo.de> wrote:
Geir,
do you set the data length (TXB0DLC)?
Regards, Michael
Am 11.01.2016 um 22:50 schrieb Geir Øyvind Vælidalo:
Hi guys!
I’m trying to send a can-messages. I copied the code from the Twizy-code, but it seems to fail for me. This is the code for sending: while (TXB0CONbits.TXREQ) {}; <— This one is ok TXB0CON = 0; TXB0SIDL = (ks_send_can.id & 0x07) << 5; TXB0SIDH = (ks_send_can.id >> 3); TXB0D0 = ks_send_can.byte[0]; TXB0D1 = ks_send_can.byte[1]; ... TXB0CON = 0b00001000; //Mark the message for sending while (TXB0CONbits.TXREQ) {}; <— Here it hangs
TXREQ seems like it never gets cleared :-\ I have CAN Write enabled, so that is not the problem.
Any ideas?
Best regards, Geir
_______________________________________________ OvmsDev mailing list OvmsDev@lists.teslaclub.hk <mailto:OvmsDev@lists.teslaclub.hk> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev <http://lists.teslaclub.hk/mailman/listinfo/ovmsdev>
-- Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal Fon 02333 / 833 5735 * Handy 0176 / 206 989 26 <dexter.vcf>_______________________________________________ OvmsDev mailing list OvmsDev@lists.teslaclub.hk http://lists.teslaclub.hk/mailman/listinfo/ovmsdev