回路図
基板図
部品並べ
ソケット上の部品あり470uFの電源コンデンサとターミナル・ブロックの位置などが多少ずれている。入出力のコネクタには以前買いだめて全然使っていなかった圧着コネクタを使ってみる予定。
焦らず騒がずぼちぼち作っていきます。
mbed: リビジョン121に戻して音声系とUI系を結合したら、まあまあちゃんと動作した。
mbed-rtos: リビジョン117
hHuse DFLED_Blink.cpp
lFuse 62
eFuse FF
#define F_CPU 10000000L #include <avr/io.h> #include <util/delay.h> int main(void) { DDRB = 0x08; while(1) { PORTB ^= 0x08; _delay_ms(100); } }
USI_TWI_Master.cpp
USI_TWI_Master.h
#define F_CPU 8000000UL #include <avr/io.h> #include "USI_TWI_Master.h" const unsigned char I2C_Address = 0xAA; // 0b10101010 const unsigned char I2C_Write = 0x01; unsigned char twiMsg[] = { I2C_Address | I2C_Write, 0x55 }; int main(void) { USI_TWI_Master_Initialise(); while(1) { USI_TWI_Start_Read_Write(twiMsg, 2); USI_TWI_Master_Stop(); } }
mbed assertation failed: _ptr == (T *)&_data, file: C:/Jenkins/workspace/mbed-2-build-library/.build/mbed/SingletonPtr.h, line 84
mbed: Revision 121 | 25 May 2016
mbed-rtos: Revision 117 | 23 May 2016
Thread(mbed::Callback<void()> task,
osPriority priority=osPriorityNormal,
uint32_t stack_size=DEFAULT_STACK_SIZE,
unsigned char *stack_pointer=NULL)
Thread(osPriority priority=osPriorityNormal,
uint32_t stack_size=DEFAULT_STACK_SIZE,
unsigned char *stack_pointer=NULL)
template <typename T, typename M>
osStatus start(T *obj, M method)
osStatus start(mbed::Callback<void()> task);
#include "mbed.h" DigitalOut led1(LED1); class Foo { public: void print() { int cnt = 0; while (true) { printf("Foo::print(): %d\r\n", cnt); cnt++; Thread::wait(100); } } }; void print() { int cnt = 0; while (true) { printf("print(): %d\r\n", cnt); cnt++; Thread::wait(100); } } int main() { printf("\r\n\n*** RTOS basic example ***\r\n"); Foo foo; Thread thread1; Thread thread2; thread1.start(&print); thread2.start(&foo, &Foo::print); while (true) { led1 = !led1; Thread::wait(500); } }
mbed assertation failed: _ptr == (T *)&_data, file: C:/Jenkins/workspace/mbed-2-build-library/.build/mbed/SingletonPtr.h, line 84というエラーが出るようになってしまった。
#include "mbed.h" #include "rtos.h" #include "st7565LCD.h" //ST7565(PinName mosi, PinName sclk, PinName cs, PinName rst, PinName a0); ST7565 gLCD(PB_15, PB_13, PB_12, PB_2, PB_1); AnalogIn Ain(A4); int main() { printf("\r\n*** st7567 & AnalogIn Test ***\r\n"); gLCD.begin(0x10); while (true) { char buff[32]; sprintf(buff, "Ain: %6u", Ain.read_u16()); gLCD.drawstring(0, 0, buff); gLCD.display(); wait(0.1); } }
#include "mbed.h" DigitalOut led1(LED1); InterruptIn sw1(D2); volatile bool isSw1Pushed = false; void sw1Pushed() { isSw1Pushed = true; } int main() { printf("\n\n*** InterruptIn example ***\n"); sw1.mode(PullUp); sw1.fall(&sw1Pushed); while (true) { led1 = !led1; printf("%d\r\n", isSw1Pushed); isSw1Pushed = false; wait(0.1); } }
sw1.fall(&sw1Pushed);で割込みハンドラをsw1Pushed()に指定すると、プルアップされなくなる(←テスタで測定)
#include <stdio.h> #include <math.h> #include <time.h> #include <stdint.h> #define M_PI_f (3.1415926f) /* pi float */ #define TABLE_LENGTH (8192) uint8_t waveTable_0[TABLE_LENGTH]; void genSineTable_double(uint8_t *table, int length) { int i; int16_t v; int8_t* p8; for (i = 0; i < length / 2; i++) { v = (int16_t)(sin(2.0 * M_PI * i * 2 / length) * 32767); p8 = (int8_t *)&v; table[i*2] = *(p8+1); table[i*2+1] = *p8; } } void genSineTable_float(uint8_t *table, int length) { int i; int16_t v; int8_t* p8; for (i = 0; i < length / 2; i++) { v = (int16_t)(sinf(2.0f * M_PI_f * i * 2 / length) * 32767); p8 = (int8_t *)&v; table[i*2] = *(p8+1); table[i*2+1] = *p8; } } int main() { clock_t start; printf("CLOCKS_PER_SEC: %ld\n", CLOCKS_PER_SEC); // 単精度浮動小数点演算 (with FPU) printf("start float: TABLE_SIZE:%d\r\n", TABLE_LENGTH); start = clock(); genSineTable_float(waveTable_0, TABLE_LENGTH); printf("%d\r\n", clock() - start); // 倍精度浮動小数点演算 printf("start double: TABLE_SIZE:%d\r\n", TABLE_LENGTH); start = clock(); genSineTable_double(waveTable_0, TABLE_LENGTH); printf("%d\r\n", clock() - start); }
TABLE_LENGTH | RasPi3 float (us) | RasPi3 double (us) | Nucleo float (us) | RasPi3 float vs Nucleo float(us) |
---|---|---|---|---|
512 | 160 | 342 | 372 | 2.325 |
1024 | 273 | 454 | 743 | 2.721611722 |
2048 | 455 | 730 | 1486 | 3.265934066 |
4096 | 897 | 1378 | 2972 | 3.313266444 |
8192 | 1621 | 2691 | 5943 | 3.666255398 |