Another short time hack. This one is for test the behavior of the spi module. Probably an Oscilloscope is required to check the wave.

Dependencies:   mbed

/media/uploads/Rhyme/test_spi.jpg

Another short time hack of mine. To check Mr. J's problem, I needed a way to control SPI in a short time. This is an aid for testing SPI module with an Oscilloscope.

You can specify, frequency, bits, mode and number of loops to let the spi write or read.

For FRDM-KL25Z MOSI: PTD2 MISO: PTD3 SCLK:PTD1

Please set "local echo on" in your terminal program.

某JさんのSPIトラブルの様子を確認するのに、作った簡単なSPIテストプログラムです。 オシロスコープでSPIの挙動を見るためのユティリティです。

FRDM-KL25Zの場合、MOSI(PTD2), MISO(PTD3), SCLK(PTD1) で使っています。

ターミナルプログラムのローカルエコーを有効にしてご使用ください。

SPIモジュールの設定(周波数、ビット、モード、そして読み書きのループ回数を設定できます。)

Revision:
3:ec7a94b41102
Parent:
2:3d2009b507f5
--- a/main.cpp	Mon May 16 06:28:42 2016 +0000
+++ b/main.cpp	Wed Jun 01 07:42:55 2016 +0000
@@ -4,21 +4,24 @@
 #include "mbed.h"
 #include <string.h>
 #include <stdio.h>
+#include "MSS.h"
 
+#if 0
 #define PIN_MOSI        PTD2
 #define PIN_MISO        PTD3 
 #define PIN_SCLK        PTD1 
 #define PIN_CS_TSC      PTA13
 #define PIN_TSC_INTR    PTC9
 #define PIN_MSS_CS      PTD0
+#endif 
 
 int freq = 1000000 ;
 int bits = 8 ;
 int mode = 0 ;
 int loop = 10 ;
 
-SPI mySpi(PIN_MOSI, PIN_MISO, PIN_SCLK) ;
-DigitalOut cs(PIN_MSS_CS, 1) ;
+SPI mySpi(PIN_MOSI, PIN_MISO, PIN_SCK) ;
+DigitalOut cs(PIN_INT0, 1) ;
 
 typedef void (*func_ptr)(void) ;