Yoann Seiller / Mbed 2 deprecated Test_UART

Dependencies:   mbed

Committer:
dyooz
Date:
Sat Oct 02 11:08:24 2021 +0000
Revision:
0:56723d925d39
Child:
1:e3bea6b4ce47
V1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dyooz 0:56723d925d39 1 /*-----------------------------------------------------------------------
dyooz 0:56723d925d39 2 Before to use this example, ensure that you an hyperterminal installed on your computer.
dyooz 0:56723d925d39 3 More info here: https://developer.mbed.org/handbook/Terminals
dyooz 0:56723d925d39 4 The default serial comm port uses the SERIAL_TX and SERIAL_RX pins (see their definition in the PinNames.h file).
dyooz 0:56723d925d39 5 The default serial configuration in this case is 9600 bauds, 8-bit data, no parity.
dyooz 0:56723d925d39 6 If you want to change the baudrate for example, you have to redeclare the
dyooz 0:56723d925d39 7 serial object in your code:
dyooz 0:56723d925d39 8
dyooz 0:56723d925d39 9 Serial pc(SERIAL_TX, SERIAL_RX);
dyooz 0:56723d925d39 10
dyooz 0:56723d925d39 11 Then, you can modify the baudrate and print like this:
dyooz 0:56723d925d39 12
dyooz 0:56723d925d39 13 pc.baud(115200);
dyooz 0:56723d925d39 14 pc.printf("Hello World !\n");
dyooz 0:56723d925d39 15 -------------------------------------------------------------------------*/
dyooz 0:56723d925d39 16 #include "mbed.h"
dyooz 0:56723d925d39 17 Serial pc(PG_14,PG_9); // Déclaration d’un objet de type Serial
dyooz 0:56723d925d39 18
dyooz 0:56723d925d39 19
dyooz 0:56723d925d39 20
dyooz 0:56723d925d39 21 int main() {
dyooz 0:56723d925d39 22 //char c ; // Variable ou ranger un caractère
dyooz 0:56723d925d39 23 int i=0;
dyooz 0:56723d925d39 24
dyooz 0:56723d925d39 25 pc.printf("\nTest liaison serie PC-Carte Nucleo\n");
dyooz 0:56723d925d39 26 pc.printf("Appuyer sur une touche du clavier \n");
dyooz 0:56723d925d39 27
dyooz 0:56723d925d39 28 while(1) {
dyooz 0:56723d925d39 29 wait(1);
dyooz 0:56723d925d39 30 i++;
dyooz 0:56723d925d39 31 printf("i = %d \n",i);
dyooz 0:56723d925d39 32 pc.putc(i);
dyooz 0:56723d925d39 33 if (i == 255){
dyooz 0:56723d925d39 34 i=0;}
dyooz 0:56723d925d39 35
dyooz 0:56723d925d39 36 }
dyooz 0:56723d925d39 37 }