I am trying to use mbed in LoRaPHY testing, which demands simple resources for:
- external interrupt for DIO0 of SX127X;
- SPI bus to SX127X;
- serial port to host;
- I2C bus to NVMEM.
I have used F103RB and mbed in some practical projects, I shouldn't raise such entry level problems. But it indeed bothers me for some days. If I added SPI into the project, the application will never go to main, it will trapped into an endless loop in class init code inside mbed library.
#include "mbed.h"
DigitalOut myled(LED1);
InterruptIn button(USER_BUTTON);
//AnalogIn testadc11(USERADC1);
AnalogIn testadc(A0);
//SPI device(SPI_MOSI, SPI_MISO, SPI_SCK);
//SPI device(SPI_MOSI, SPI_MISO, SPI_SCK, NC);
I2C i2c(I2C_SDA, I2C_SCL);
Serial pc(SERIAL_TX, SERIAL_RX);
void key_isr() {
myled = !myled;
}
void setup() {
button.fall(&key_isr);
}
int main() {
int i=0;
setup();
while(1) {
myled = 1; // LED is ON
wait(0.2); // 200 ms
myled = 0; // LED is OFF
wait(1.0); // 1 sec
//device.write(0x55);
//device.write(i++);
//device.write(0xE0);
pc.printf("test\r\n");
}
}
If I comment out SPI code, the LED can toggle, keyboard works as well. If I enable SPI code, main entry loop will not be hit, if we see the code in uvision4, we can find it is in an endless loop.
Is there any wrong in my code or mbed library for STM32F103RB? I use similiar code in LPC812, it works.
I am trying to use mbed in LoRaPHY testing, which demands simple resources for:
I have used F103RB and mbed in some practical projects, I shouldn't raise such entry level problems. But it indeed bothers me for some days. If I added SPI into the project, the application will never go to main, it will trapped into an endless loop in class init code inside mbed library.
If I comment out SPI code, the LED can toggle, keyboard works as well. If I enable SPI code, main entry loop will not be hit, if we see the code in uvision4, we can find it is in an endless loop.
Is there any wrong in my code or mbed library for STM32F103RB? I use similiar code in LPC812, it works.