Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 /* Program Example 13.4: CAN data write – sends an incrementing count value to the CAN bus every second. 00002 */ 00003 #include "mbed.h" 00004 Serial pc(USBTX, USBRX); // tx, rx for Tera Term output 00005 00006 DigitalOut led1(LED1); // status LED 00007 CAN can1(p30, p29); // CAN interface 00008 char counter = 0; 00009 int main() { 00010 printf("send... "); 00011 while (1) { 00012 // send value to CAN bus and monitor return value to check if CAN 00013 // message was sent successfully. If so display, increment and toggle 00014 if (can1.write(CANMessage(1, &counter, 1))) { 00015 pc.printf("Message sent: %d\n", counter); // display 00016 counter++; // increment 00017 led1 = !led1; // toggle status LED 00018 }else{ 00019 can1.reset(); 00020 } 00021 wait(1); 00022 } 00023 }
Generated on Sat Aug 20 2022 01:37:08 by
1.7.2