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.
Dependencies: mbed
Fork of SPI_master_frdm by
Diff: main.cpp
- Revision:
- 3:8f2dc71bae92
- Parent:
- 2:52f588020826
- Child:
- 4:995eae7f13f4
diff -r 52f588020826 -r 8f2dc71bae92 main.cpp
--- a/main.cpp Wed Mar 18 14:29:03 2015 +0000
+++ b/main.cpp Wed Apr 01 09:05:22 2015 +0000
@@ -2,15 +2,19 @@
//SPI Master
-SPI spi(p25, p28, p29); // mosi, miso, sclk
+SPI spi(D11, D12, D13); // mosi, miso, sclk
+//SPI spi(PTA16, PTA17, PTA15);
Serial pc(USBTX, USBRX);
DigitalOut led(LED1);
-DigitalOut cs(p24);
+DigitalOut cs(D10);
+//DigitalOut cs(PTB9);
+//DigitalOut cs(D8);
+//DigitalOut cs(PTA14);
int main() {
- spi.format(8,0); //not usefull results
- spi.frequency(1000000);
+ spi.format(8,0);
+ spi.frequency(100000);
uint8_t i;
int j = 0;
uint8_t fail;
@@ -20,14 +24,26 @@
fail = 0;
success = 0;
- for (i = 0; i < 32; i++) {
+ for (i = 0; i < 10; i++) {
+
+ wait_ms(100);
cs = 0;
+ wait_ms(100);
spi.write(i);
+ wait_ms(100);
cs = 1;
+
+ wait_ms(100);
+
cs = 0;
+ wait_ms(100);
uint8_t response = spi.write(0xFF);
+ wait_ms(100);
cs = 1;
+ wait_ms(100);
+
+ printf("instruction: %x response: %x\r\n", i, response);
if(response == i + 0x10) {
success++;
@@ -35,10 +51,12 @@
fail++;
}
+ wait_ms(500);
+
}
pc.printf("%d: fails: %d, success: %d\r\n",j++ , fail, success);
- wait(.5);
+ wait(1.5);
}
