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, 7 months ago.
CAN Hello World Example
Hello Mbed Team,
This is santhosh and im trying to work with the CAN code over here , im using 2 can tranceiver chips mcp 2551 and the bus is terminated with 250 ohm resistor and rs pin of the transceiver grounded but still unable to receive messages from the bus . I have attached the code ,snapshot from hyper terminal and connection schematic . please lemme know whether there's any mistake .
Expecting quick response from your side .
Can Tx code (Running on 1st board)
- include "mbed.h"
CAN can2(p30, p29);
char counter=0;
void send() {
if(can2.write(CANMessage(20, &counter, 1))) { printf("wloop()\n"); counter++; printf("\n Message sent: %d", counter); }
} int main() {
printf("main()\n");
while(1) {
send();
} }
CAN RX(Running on second board)
- include "mbed.h" CAN can2(p30, p29); int main() { CANMessage msg; while(1) {
if(can2.read(msg)) {
printf("\n Message received:%d", msg.data[0]);
wait(0.2); } }
}
Question relating to:
2 Answers
11 years, 7 months ago.
Check this page for some hints: http://mbed.org/forum/mbed/topic/4229/?page=1#comment-20991
11 years, 7 months ago.
Hi Mr Wim,
Sorry for the delay in responding , there was a problem in wiring and it was not reading the message .I rewired the whole circuit and its fixed .