Το Mbed NXP LPC1768 μπορεί να χρησιμοποιηθεί για “Rapid Prototyping for general microcontroller applications, Ethernet, USB and 32-bit ARM® Cortex™-M3 based designs.” Το Σχήμα παρακάτω δίνει το διάγραμμα των ακίδων του Mbed NXP LPC1768. Γενικές πληροφορίες για το Mbed NXP LPC1768 μπορείτε να βρείτε στην ιστοσελίδα http://developer.mbed.org/platforms/mbed-LPC1768/.
Δες επίσης mbed NXP LPC1768 Schematic
Η σειριακή επικοινωνία μπορεί να υλοποιηθεί πάνω από τις ακίδες Serial (σχήμα 2) και πάνω από την USB σύνδεση με τον υπολογιστή σας. Η τελευταία επιλογή σας δίνει τη δυνατότητα να υλοποιήσετε μια virtual σειριακή επικοινωνία πάνω από την USB σύνδεση του board με τον υπολογιστή σας.
Την virtual σειριακή θύρα μπορείτε να δείτε από τον Device Manager κάτω από τα PORTS. Εμφανίζεται ως “mbed Serial Port (COMX)” όπως στο σχήμα παρακάτω.
Αν δεν βλέπετε την mbed Serial Port θα πρέπει πιθανότατα να εγκαταστήσετε τον “mbed Windows serial port driver” καθώς “The mbed serial port works by default on Mac and Linux, but Windows needs a driver.” https://developer.mbed.org/handbook/ Windows-serial-configuration
Στον παραπάνω σύνδεσμο θα βρείτε και οδηγίες “how to setup the mbed Microcontroller to use the USB serial port on Windows.”
Για να αξιοποιήσετε από το mbed την virtual σειριακή θύρα δημιουργήστε στο πρόγραμμα σας ένα στιγμιότυπο της κλάσης Serial (https://developer.mbed.org/handbook/Serial) πάνω από την USB σύνδεση χρησιμοποιώντας κατάλληλα τον constructor της Serial κλάσης, όπου αντί για ακίδες θα χρησιμοποιηθούν τα USBTX και USBRX.
Στην ιστοσελίδα https://developer.mbed.org/handbook/Homepage θα βρείτε τεκμηρίωση για την βιβλιοθήκη mbed.
Η παρακάτω πρόταση δημιουργεί ένα στιγμιότυπο της Serial πάνω από την USB σύνδεση με όνομα pc.
Serial pc(USBTX, USBRX); // tx, rx
Στη συνέχεια χρησιμοποιήστε τις μεθόδους printf και scanf, (π.χ., pc.printf("Hello World\n");) για να γράψετε και να διαβάσετε από την σειριακή θύρα. Αυτό βέβαια προϋποθέτει:
a) να έχετε ανοίξει ένα terminal στον υπολογιστή και να το έχετε συνδέσει στην mbed serial πόρτα του (σχήμα 6) , και
b) να έχετε ορίσει τις παραμέτρους επικοινωνίας του terminal σύμφωνα με τις default του mbed (σχήμα 7).
Σχήμα 6. Σύνδεση του Tera Term terminal με την virtual σειριακή θύρα του mbed.
Σχήμα 7. Ορισμός παραμέτρων επικοινωνίας του terminal (Setup-Serial).
Παράμετροι επικοινωνίας
Προσέξτε τις default παραμέτρους επικοινωνίας στο embedded board
«The Serial Interface defaults to a 9600 baud standard serial connection (8 bits, 1 stop bit, no parity), so your host program should be set to the same settings. If you want to communicate at a different standard baud rate, ensure you modify the settings of both the Serial Interface and the Host PC application!»
Αν τα παραπάνω ισχύουν θα δείτε στην εφαρμογή του terminal το Hello World που αντιστοιχεί στην pc.printf("Hello World\n");
“Terminal applications run on your host PC, and provide a window for your mbed Microcontroller to print to, and a means for you to type characters back to your mbed Microcontroller.” https://developer.mbed.org/handbook/Terminals
The mbed SDK
The mbed Software Development Kit (SDK) is a C/C++ microcontroller software platform relied upon by tens of thousands of developers to build projects fast. We've worried about creating and testing startup code, C runtime, libraries and peripheral APIs, so you can worry about coding the smarts of your next product.
The SDK is licensed under the permissive Apache 2.0 licence, so you can use it in both commercial and personal projects with confidence.
The mbed SDK has been designed to provide enough hardware abstraction to be intuitive and concise, yet powerful enough to build complex projects. It is built on the low-level ARM CMSIS APIs, allowing you to code down to the metal if needed. In addition to RTOS, USB and Networking libraries, a cookbook of hundreds of reusable peripheral and module libraries have been built on top of the SDK by the mbed Developer Community. Source: https://developer.mbed.org/handbook/mbed-SDK
Στο αρχείο επικεφαλίδας SerialBase.h της mbed library μπορείτε να βρείτε τα function prototypes όλων των συναρτήσεων που υποστηρίζουν την αξιοποίηση του Serial port.
Επικοινωνία με τον host PC
Για να δείτε πως ο “mbed Microcontroller can communicate with a host PC through a "USB Virtual Serial Port" over the same USB cable that is used for programming.» ανατρέξτε στην ιστοσελίδα «Serial Communication with a PC» http://developer.mbed.org/handbook/SerialPC
Η δυνατότητα αυτή σας επιτρέπει να:
Print out messages to a host PC terminal (useful for debugging!)
Read input from the host PC keyboard
Communicate with applications and programming languages running on the host PC that can communicate with a serial port, e.g. perl, python, java and so on.