Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years ago.
Canbus example not working, but including src and output seperately
Didn't realise that any formatting of source code is removed when cutting and pasting to question area, so re-asking same question....
Have uploaded source code and hyperterminal output.
Basically just a copy of example CAN code with minor modifications of printfs to allow printing to hyperterminal. Also, used a breadboard to directly connect pin 9 to pin 29 and pin 10 to pin 30 without going through a transceiver.
Program sends OK but will not receive anything.
Any help appreciated.
/media/uploads/murrayhaszard/main.cpp /media/uploads/murrayhaszard/hyperterminal.txt
Question relating to:
1 Answer
11 years ago.
Quote:
Didn't realise that any formatting of source code is removed when cutting and pasting to question area, so re-asking same question....
Enclose you code between <<code>> and <</code>>
when you want post it to the wiki in the correct format.
The CAN example should work withour drivers. I have tested it as a CAN1-CAN2 loop on a board with CAN drivers. Are you using the lpc1768 mbed? Have you checked the wiring for good connectivity?
Thanks for comments Wim. I wrote a small program to double check that Pin10 was connected properly to Pin30 and Pin29 connected to Pin9 which is here...
// mhserial2.cpp // Test writing to pin 29 and reading from pin 9 // Test writing to pin 10 and reading from pin 30 #include "mbed.h" Serial pc(USBTX,USBRX); DigitalIn pin9(p9); DigitalIn pin30(p30); DigitalOut pin29(p29); DigitalOut pin10(p10); int i; char b9,b10,b29,b30; int main() { pc.printf("mhserial2 - test pins 29->9 and pins 10->30\n\r"); // Pin 29 connected to pin 9 // Pin 10 connected to pin 30 for(i=0;i<4;i++){ b10 = (i & 1); b29 = ((i & 2)>>1); pin10 = b10; pin29 = b29; b9 = pin9; b30 = pin30; pc.printf("(%d)\n\r",i); pc.printf("..p29 = %d, p10 = %d\n\r",(int)b29,(int)b10); pc.printf("..p09 = %d, p30 = %d\n\r",(int)b9,(int)b30); wait(0.2); } pc.printf("\n\rFinish\n\r"); } //And here is the output of the test program.... mhserial2 - test pins 29->9 and pins 10->30 (0) ..p29 = 0, p10 = 0 ..p09 = 0, p30 = 0 (1) ..p29 = 0, p10 = 1 ..p09 = 0, p30 = 1 (2) ..p29 = 1, p10 = 0 ..p09 = 1, p30 = 0 (3) ..p29 = 1, p10 = 1 ..p09 = 1, p30 = 1 Finish
Which seems to prove the wiring is OK. Canbus example still only sends, same as previous. I re-did the wiring to double check. Yes I am using the lpc1768 mbed.
posted by 25 Apr 2013
Turns out that just connecting pins 9 to 29 and 10 to 30 doesn't work. There is an example of how to wire a network without transceivers in the CAN primer pdf at http://www.keil.com/download/files/canprimer_v2.pdf under heading "A Tiny Network without Transceiver ICs:"
posted by Murray Haszard 29 Apr 2013