Test program for SoftSerial. TimerEvent function has bug for STM32 series Mbed. FRDM-64K works well without bug. This is a temporary solution avoid bug but not perfect.

Dependencies:   BufferedSoftSerial

Files at this revision

API Documentation at this revision

Comitter:
kenjiArai
Date:
Tue May 12 05:44:33 2020 +0000
Parent:
0:98865e300cd5
Commit message:
expand for several CPU's

Changed in this revision

0_main.cpp Show diff for this revision Revisions of this file
1_main.cpp Show diff for this revision Revisions of this file
2_main.cpp Show diff for this revision Revisions of this file
3_main.cpp Show diff for this revision Revisions of this file
BufferedSoftSerial.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
select_example.h Show diff for this revision Revisions of this file
--- a/0_main.cpp	Sun May 10 08:15:36 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/*
- * Mbed Application program
- *  SoftSerial(also BufferedSoftSerial) function test programs
- *  UART 3 channels
- *      (1) Mbed Serial communication line as "pc"
- *      (2) CPU another UART channel as "ser"
- *      (3) Software Serial channel as "dev"
- *
- * Copyright (c) 2020 Kenji Arai / JH1PJL
- *  http://www7b.biglobe.ne.jp/~kenjia/
- *  https://os.mbed.com/users/kenjiArai/
- *      Created:    May        9th, 2020
- *      Revised:    May       10th, 2020
- */
-
-/*
-    Tested board on OS5.15.3
-        Nucleo-F446RE, Nucleo-L432KC
- */
-
-//  Pre-selection --------------------------------------------------------------
-#include    "select_example.h"
-//#define EXAMPLE_0
-#ifdef EXAMPLE_0
-#warning "Select 0"
-
-//  Include --------------------------------------------------------------------
-#include "mbed.h"
-#include "BufferedSoftSerial.h"
-
-//  Definition -----------------------------------------------------------------
-#define BEFFERED    1
-    
-//  Constructor ----------------------------------------------------------------
-#if defined(TARGET_NUCLEO_L432KC)
-DigitalOut test_point(D12);
-Serial ser(D5, D4, 9600);
-#   if BEFFERED
-    BufferedSoftSerial dev(D6,D3);
-#   else
-    SoftSerial dev(D6,D3);
-#   endif
-#elif defined(TARGET_NUCLEO_F446RE)
-DigitalOut test_point(A0);
-Serial ser(D8, D2, 9600);
-#   if BEFFERED
-    BufferedSoftSerial dev(D4,D3);
-#   else
-    SoftSerial dev(D4,D3);
-#   endif
-#endif
-Serial pc(USBTX,USBRX, 9600);
-
-//  RAM ------------------------------------------------------------------------
-
-//  ROM / Constant data --------------------------------------------------------
-
-//  Function prototypes --------------------------------------------------------
-
-//------------------------------------------------------------------------------
-//  Control Program
-//------------------------------------------------------------------------------
-/*
-    UART 3 channels
-        (1) Mbed Serial communication line as "pc"
-        (2) CPU another UART channel as "ser"
-        (3) Software Serial channel as "dev"
- */
-int main()
-{
-    int count = 0;
-    while(true) {
-        for (uint32_t i = '!'; i < '~'; i++) {
-            dev.putc(i);        // output to softserial
-            ser.putc(i);        // output to another UART
-            pc.putc(i);         // output to PC
-        }
-        dev.puts("----> ABCDEFGHIJKLMOPQRSTUVWXYZ0123456789");
-        ser.puts("----> ABCDEFGHIJKLMOPQRSTUVWXYZ0123456789");
-        pc.puts( "----> ABCDEFGHIJKLMOPQRSTUVWXYZ0123456789");
-        dev.printf("--------->%4d\r\n", count);
-        ser.printf("--------->%4d\r\n", count);
-        pc.printf( "--------->%4d\r\n", count++);
-    }
-}
-
-#endif //#ifdef EXAMPLE_0
--- a/1_main.cpp	Sun May 10 08:15:36 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
- * Mbed Application program
- *  SoftSerial(also BufferedSoftSerial) function test programs
- *  UART 3 channels
- *      (1) Mbed Serial communication line as "pc"
- *      (2) CPU another UART channel as "ser"
- *      (3) Software Serial channel as "dev"
- *
- * Copyright (c) 2020 Kenji Arai / JH1PJL
- *  http://www7b.biglobe.ne.jp/~kenjia/
- *  https://os.mbed.com/users/kenjiArai/
- *      Created:    May        9th, 2020
- *      Revised:    May       10th, 2020
- */
-
-/*
-    Tested board on OS5.15.3
-        Nucleo-F446RE, Nucleo-L432KC
- */
-
-//  Pre-selection --------------------------------------------------------------
-#include    "select_example.h"
-//#define EXAMPLE_1
-#ifdef EXAMPLE_1
-#warning "Select 1"
-
-//  Include --------------------------------------------------------------------
-#include "mbed.h"
-#include "BufferedSoftSerial.h"
-
-//  Definition -----------------------------------------------------------------
-#define BEFFERED    1
-    
-//  Constructor ----------------------------------------------------------------
-#if defined(TARGET_NUCLEO_L432KC)
-DigitalOut test_point(D12);
-Serial ser(D5, D4, 9600);
-#   if BEFFERED
-    BufferedSoftSerial dev(D6,D3);
-#   else
-    SoftSerial dev(D6,D3);
-#   endif
-#elif defined(TARGET_NUCLEO_F446RE)
-DigitalOut test_point(A0);
-Serial ser(D8, D2, 9600);
-#   if BEFFERED
-    BufferedSoftSerial dev(D4,D3);
-#   else
-    SoftSerial dev(D4,D3);
-#   endif
-#endif
-Serial pc(USBTX,USBRX, 9600);
-
-//  RAM ------------------------------------------------------------------------
-
-//  ROM / Constant data --------------------------------------------------------
-
-//  Function prototypes --------------------------------------------------------
-
-//------------------------------------------------------------------------------
-//  Control Program
-//------------------------------------------------------------------------------
-/*
-    UART 3 channels
-        (1) Mbed Serial communication line as "pc"
-        (2) CPU another UART channel as "ser"
-        (3) Software Serial channel as "dev"
- */
-int main()
-{
-    while(true) {
-        char c = pc.getc(); // get serial data
-        dev.putc(c);        // send softserail line
-        ser.putc(c);        // another UART
-        pc.putc(c);         // echo back to PC
-    }
-}
-
-#endif //#ifdef EXAMPLE_1
--- a/2_main.cpp	Sun May 10 08:15:36 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
- * Mbed Application program
- *  SoftSerial(also BufferedSoftSerial) function test programs
- *  UART 3 channels
- *      (1) Mbed Serial communication line as "pc"
- *      (2) CPU another UART channel as "ser"
- *      (3) Software Serial channel as "dev"
- *
- * Copyright (c) 2020 Kenji Arai / JH1PJL
- *  http://www7b.biglobe.ne.jp/~kenjia/
- *  https://os.mbed.com/users/kenjiArai/
- *      Created:    May        9th, 2020
- *      Revised:    May       10th, 2020
- */
-
-/*
-    Tested board on OS5.15.3
-        Nucleo-F446RE, Nucleo-L432KC
- */
-
-//  Pre-selection --------------------------------------------------------------
-#include    "select_example.h"
-//#define EXAMPLE_2
-#ifdef EXAMPLE_2
-#warning "Select 2"
-
-//  Include --------------------------------------------------------------------
-#include "mbed.h"
-#include "BufferedSoftSerial.h"
-
-//  Definition -----------------------------------------------------------------
-#define BEFFERED    1
-    
-//  Constructor ----------------------------------------------------------------
-#if defined(TARGET_NUCLEO_L432KC)
-DigitalOut test_point(D12);
-Serial ser(D5, D4, 9600);
-#   if BEFFERED
-    BufferedSoftSerial dev(D6,D3);
-#   else
-    SoftSerial dev(D6,D3);
-#   endif
-#elif defined(TARGET_NUCLEO_F446RE)
-DigitalOut test_point(A0);
-Serial ser(D8, D2, 9600);
-#   if BEFFERED
-    BufferedSoftSerial dev(D4,D3);
-#   else
-    SoftSerial dev(D4,D3);
-#   endif
-#endif
-Serial pc(USBTX,USBRX, 9600);
-
-//  RAM ------------------------------------------------------------------------
-
-//  ROM / Constant data --------------------------------------------------------
-
-//  Function prototypes --------------------------------------------------------
-
-//------------------------------------------------------------------------------
-//  Control Program
-//------------------------------------------------------------------------------
-/*
-    UART 3 channels
-        (1) Mbed Serial communication line as "pc"
-        (2) CPU another UART channel as "ser"
-        (3) Software Serial channel as "dev"
- */
-int main()
-{
-    while(true) {
-        char c = dev.getc();// get serial data
-        dev.putc(c);        // echo back to softserial port
-        ser.putc(c);        // another UART
-        pc.putc(c);         // Mbed Serial
-    }
-}
-
-#endif //#ifdef EXAMPLE_2
\ No newline at end of file
--- a/3_main.cpp	Sun May 10 08:15:36 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-/*
- * Mbed Application program
- *  SoftSerial(also BufferedSoftSerial) function test programs
- *  UART 3 channels
- *      (1) Mbed Serial communication line as "pc"
- *      (2) CPU another UART channel as "ser"
- *      (3) Software Serial channel as "dev"
- *
- * Copyright (c) 2020 Kenji Arai / JH1PJL
- *  http://www7b.biglobe.ne.jp/~kenjia/
- *  https://os.mbed.com/users/kenjiArai/
- *      Created:    May        9th, 2020
- *      Revised:    May       10th, 2020
- */
-
-/*
-    Tested board on OS5.15.3
-        Nucleo-F446RE, Nucleo-L432KC
- */
-
-//  Pre-selection --------------------------------------------------------------
-#include    "select_example.h"
-//#define EXAMPLE_3
-#ifdef EXAMPLE_3
-#warning "Select 3"
-
-//  Include --------------------------------------------------------------------
-#include "mbed.h"
-#include "BufferedSoftSerial.h"
-
-//  Definition -----------------------------------------------------------------
-#if (MBED_MAJOR_VERSION == 2)
-#error "Cannot run on OS2"
-#endif
-
-//  Constructor ----------------------------------------------------------------
-#if defined(TARGET_NUCLEO_L432KC)
-DigitalOut test_point(D12);
-Serial ser(D5, D4, 9600);
-BufferedSoftSerial dev(D6,D3);
-#elif defined(TARGET_NUCLEO_F446RE)
-DigitalOut test_point(A0);
-Serial ser(D8, D2, 9600);
-BufferedSoftSerial dev(D4,D3);
-#endif
-Serial pc(USBTX,USBRX, 9600);
-
-//  RAM ------------------------------------------------------------------------
-
-//  ROM / Constant data --------------------------------------------------------
-
-//  Function prototypes --------------------------------------------------------
-void pc2dev(void const *args);
-void dev2pc(void const *args);
-
-//------------------------------------------------------------------------------
-//  Control Program
-//------------------------------------------------------------------------------
-osThreadDef(pc2dev, osPriorityNormal,1024);
-osThreadDef(dev2pc, osPriorityNormal,1024);
-
-int main()
-{
-    // Start tasks
-    osThreadCreate(osThread(pc2dev), NULL);
-    osThreadCreate(osThread(dev2pc), NULL);
-    // main routine
-    int count = 0;
-    while(true) {
-        ser.printf( "Time passed %4d [sec]\r\n", count++);
-        ThisThread::sleep_for(1000);
-    }
-}
-
-void pc2dev(void const *args)
-{
-    while(true) {
-        if (pc.readable()) {
-            dev.putc(pc.getc());
-        } else {
-            ThisThread::yield();
-        }
-    }
-}
-
-void dev2pc(void const *args)
-{
-    while(true) {
-        if (dev.readable()) {
-            pc.putc(dev.getc());
-        } else {
-            ThisThread::yield();
-        }
-    }
-}
-
-#endif //#ifdef EXAMPLE_3
\ No newline at end of file
--- a/BufferedSoftSerial.lib	Sun May 10 08:15:36 2020 +0000
+++ b/BufferedSoftSerial.lib	Tue May 12 05:44:33 2020 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/kenjiArai/code/BufferedSoftSerial/#f186cc69acdf
+https://os.mbed.com/users/kenjiArai/code/BufferedSoftSerial/#7ab9ab7210e7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue May 12 05:44:33 2020 +0000
@@ -0,0 +1,96 @@
+/*
+ * Mbed Application program
+ *  SoftSerial(also BufferedSoftSerial) function test programs
+ *  UART 2 channels
+ *      (1) Mbed Serial communication line as "pc"
+ *      (2) Software Serial channel as "dev"
+ *
+ * Copyright (c) 2020 Kenji Arai / JH1PJL
+ *  http://www7b.biglobe.ne.jp/~kenjia/
+ *  https://os.mbed.com/users/kenjiArai/
+ *      Created:    May        9th, 2020
+ *      Revised:    May       12th, 2020
+ */
+
+/*
+    Tested board on OS5.15.3
+        Nucleo-L152RE,
+        Nucleo-F401RE, -F411RE, -F446RE,
+        Nucleo-L432KC, -L476RG
+        FRDM-K64F
+        
+    CAUTION!!
+        Due to bug inside TimerEvent, not stable on STM32 series Mbed
+        at this moment.
+        FRDM-K40 works fine(no trouble TimerEvent function).
+ */
+
+//  Include --------------------------------------------------------------------
+#include "mbed.h"
+#include "BufferedSoftSerial.h"
+
+//  Definition -----------------------------------------------------------------
+#define BAUD    9600
+//#define BAUD    14400
+//#define BAUD    19200  // No continuous transmission           
+//#define BAUD    38400  // NOT SUCCESS!!
+
+//  Constructor ----------------------------------------------------------------
+#if defined(TARGET_NUCLEO_L432KC)
+DigitalOut test_point(D12);
+Serial ser(D5, D4, BAUD);
+BufferedSoftSerial dev(D6,D3);
+#else
+DigitalOut test_point(A0);
+BufferedSoftSerial dev(D4,D3);
+#endif
+Serial pc(USBTX,USBRX, BAUD);
+
+//  RAM ------------------------------------------------------------------------
+
+//  ROM / Constant data --------------------------------------------------------
+
+//  Function prototypes --------------------------------------------------------
+void pc2dev(void const *args);
+void dev2pc(void const *args);
+
+//------------------------------------------------------------------------------
+//  Control Program
+//------------------------------------------------------------------------------
+osThreadDef(pc2dev, osPriorityNormal,1024);
+osThreadDef(dev2pc, osPriorityNormal,1024);
+
+int main()
+{
+    dev.baud(BAUD);
+    // Start tasks
+    osThreadCreate(osThread(pc2dev), NULL);
+    osThreadCreate(osThread(dev2pc), NULL);
+    while(true) {
+        ThisThread::sleep_for(1000000);
+    }
+}
+
+void pc2dev(void const *args)
+{
+    pc.printf("\r\nStart program\r\n");
+    while(true) {
+        if (pc.readable()) {
+            dev.putc(pc.getc());
+        } else {
+            ThisThread::yield();
+        }
+    }
+}
+
+void dev2pc(void const *args)
+{
+    dev.printf("\r\nStart program\r\n");
+    while(true) {
+        if (dev.readable()) {
+            pc.putc(dev.getc());
+        } else {
+            ThisThread::yield();
+        }
+    }
+}
--- a/select_example.h	Sun May 10 08:15:36 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-/*
- * Mbed Application program
- *  SoftSerial(also BufferedSoftSerial) function test programs
- *
- * Copyright (c) 2020 Kenji Arai / JH1PJL
- *  http://www7b.biglobe.ne.jp/~kenjia/
- *  https://os.mbed.com/users/kenjiArai/
- *      Created:    May        9th, 2020
- *      Revised:    May       10th, 2020
- */
-
-#define EXAMPLE_NUMBER      0       // select 0 to 3
-
-//----------------- You don't need any modification ----------------------------
-#if EXAMPLE_NUMBER   == 0
-#   define EXAMPLE_0
-#elif EXAMPLE_NUMBER == 1
-#   define EXAMPLE_1
-#elif EXAMPLE_NUMBER == 2
-#   define EXAMPLE_2
-#elif EXAMPLE_NUMBER == 3
-#   define EXAMPLE_3
-#else
-#   error " Please set 0 to 3 number for EXAMPLE_NUMBER!!"
-#endif
\ No newline at end of file