Hello all,
I'm new to stm32duino (one week), sorry about that. Until now, I only programmed for AVR. Currently working on the project: LoRa RF95 (SPI) + BME280 (I2C) + BH1750 (I2C) + Oled SSD1306 (SPI) + of course STM32 .
I have one success and a million questions. I started my project on STM32F103C8 blue pill from china. It works very well. My work environment:
- Arduino 1.8.12
- Board manager: http://dan.drown.org/stm32duino/package ... index.json (is this Roger ??)
- RadioHead library http://www.airspayce.com/mikem/arduino/ ... -1.101.zip
STM32 is talking to Nano V3 - great. Program STM32 via ST-LINK V2 - Super.
First problem: If I choose a board from https://github.com/stm32duino/BoardMana ... index.json the sketch does not compile.
Even if I use the example from the RadioHead library, there are errors. Can I do something to fix it?
Second problem: can I use ST-LINK V2 for boards from https://github.com/stm32duino/BoardMana ... index.json ?? This option is missing, I can't find it.
Next issue, I ordered the STM32F401CCU6 boards, but for them the RadioHead compilation always fails (even for an example). Here boards from https://github.com/stm32duino/BoardMana ... index.json work better, because only for them the libraries BME280, BH1750 and U8glib.h are ok.
Is there any way to radio LoRa RF95 for https://github.com/stm32duino/BoardMana ... index.json? Of course I can use blue, but black looks better;)
I apologize for the long text and the poor English.
Blue pill, black pill and RadioHead library
Re: Blue pill, black pill and RadioHead library
http://dan.drown.org/stm32duino/package ... index.json - is a roger's core
https://github.com/stm32duino/BoardMana ... index.json - an official core
about radiohead library
as described here - https://www.airspayce.com/mikem/arduino/RadioHead/ it's compatible with official core as well as with rogers (but he mentioned strange hangs with roger's core) so till you are hiding compile errors no one can help
About st-link and official core, install STM32 Cube Programmer from here
and chose Stm32CubeProgrammer (SWD) option
https://github.com/stm32duino/BoardMana ... index.json - an official core
about radiohead library
as described here - https://www.airspayce.com/mikem/arduino/RadioHead/ it's compatible with official core as well as with rogers (but he mentioned strange hangs with roger's core) so till you are hiding compile errors no one can help
About st-link and official core, install STM32 Cube Programmer from here
and chose Stm32CubeProgrammer (SWD) option
Re: Blue pill, black pill and RadioHead library
Thank you for your reply and information. Of course I will check the STM32 Cube Programmer + Stm32CubeProgrammer (SWD).
Regarding the sketch, which with Roger's core compiles and works well on the board, if I set the official core:
- Generic SMT32F1 series
- BluePill F103C8 64Kb
the compiler stops with such errors:
My sketch is "ugly" (test version), but of course I can also paste it. I can also clean it and paste only what I have a problem with.
Regarding the sketch, which with Roger's core compiles and works well on the board, if I set the official core:
- Generic SMT32F1 series
- BluePill F103C8 64Kb
the compiler stops with such errors:
Code: Select all
Arduino:1.8.12 (Windows 7), Płytka:"Generic STM32F1 series, BluePill F103C8, STM32CubeProgrammer (SWD), Enabled (generic 'Serial'), None, Low/Full Speed, Smallest (-Os default), Newlib Nano (default)"
C:\Users\1234\Documents\Arduino\libraries\RadioHead\RH_ASK.cpp:18:21: error: invalid conversion from 'int' to 'TIM_TypeDef*' [-fpermissive]
18 | HardwareTimer timer(1);
| ^
| |
| int
In file included from C:\Users\1234\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\cores\arduino/stm32/analog.h:45,
from C:\Users\1234\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\cores\arduino/board.h:8,
from C:\Users\1234\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\cores\arduino/wiring.h:41,
from C:\Users\1234\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\cores\arduino/Arduino.h:32,
from C:\Users\1234\Documents\Arduino\libraries\RadioHead/RadioHead.h:1298,
from C:\Users\1234\Documents\Arduino\libraries\RadioHead/RHGenericDriver.h:9,
from C:\Users\1234\Documents\Arduino\libraries\RadioHead/RH_ASK.h:9,
from C:\Users\1234\Documents\Arduino\libraries\RadioHead\RH_ASK.cpp:6:
C:\Users\1234\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\cores\arduino/HardwareTimer.h:98:32: note: initializing argument 1 of 'HardwareTimer::HardwareTimer(TIM_TypeDef*)'
98 | HardwareTimer(TIM_TypeDef *instance);
| ~~~~~~~~~~~~~^~~~~~~~
C:\Users\1234\Documents\Arduino\libraries\RadioHead\RH_ASK.cpp: In member function 'void RH_ASK::timerSetup()':
C:\Users\1234\Documents\Arduino\libraries\RadioHead\RH_ASK.cpp:188:11: error: 'class HardwareTimer' has no member named 'setPeriod'
188 | timer.setPeriod((1000000/8)/_speed);
| ^~~~~~~~~
C:\Users\1234\Documents\Arduino\libraries\RadioHead\RH_ASK.cpp:190:11: error: 'class HardwareTimer' has no member named 'setChannel1Mode'; did you mean 'TimerModes_t HardwareTimer::_ChannelMode [4]'? (not accessible from this context)
190 | timer.setChannel1Mode(TIMER_OUTPUT_COMPARE);
| ^~~~~~~~~~~~~~~
In file included from C:\Users\1234\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\cores\arduino/stm32/analog.h:45,
from C:\Users\1234\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\cores\arduino/board.h:8,
from C:\Users\1234\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\cores\arduino/wiring.h:41,
from C:\Users\1234\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\cores\arduino/Arduino.h:32,
from C:\Users\1234\Documents\Arduino\libraries\RadioHead/RadioHead.h:1298,
from C:\Users\1234\Documents\Arduino\libraries\RadioHead/RHGenericDriver.h:9,
from C:\Users\1234\Documents\Arduino\libraries\RadioHead/RH_ASK.h:9,
from C:\Users\1234\Documents\Arduino\libraries\RadioHead\RH_ASK.cpp:6:
C:\Users\1234\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\cores\arduino/HardwareTimer.h:152:19: note: declared private here
152 | TimerModes_t _ChannelMode[TIMER_CHANNELS];
| ^~~~~~~~~~~~
C:\Users\1234\Documents\Arduino\libraries\RadioHead\RH_ASK.cpp:191:11: error: 'class HardwareTimer' has no member named 'setCompare'
191 | timer.setCompare(TIMER_CH1, 1); // Interrupt 1 count after each update
| ^~~~~~~~~~
C:\Users\1234\Documents\Arduino\libraries\RadioHead\RH_ASK.cpp:191:22: error: 'TIMER_CH1' was not declared in this scope; did you mean 'TIMER_NUM'?
191 | timer.setCompare(TIMER_CH1, 1); // Interrupt 1 count after each update
| ^~~~~~~~~
| TIMER_NUM
C:\Users\1234\Documents\Arduino\libraries\RadioHead\RH_ASK.cpp:193:11: error: 'class HardwareTimer' has no member named 'attachCompare1Interrupt'; did you mean 'attachInterrupt'?
193 | timer.attachCompare1Interrupt(interrupt);
| ^~~~~~~~~~~~~~~~~~~~~~~
| attachInterrupt
exit status 1
Błąd kompilacji dla płytki Generic STM32F1 series.
Ten raport powinien zawierać więcej informacji jeśli w
File -> Preferencje zostanie włączona opcja "Pokaż
szczegółowe informacje podczas kompilacji"
Re: Blue pill, black pill and RadioHead library
Official core have a different hardware timer api, so its required to fix library to work with this core
https://github.com/stm32duino/wiki/wiki ... er-library
https://github.com/stm32duino/wiki/wiki ... er-library
Re: Blue pill, black pill and RadioHead library
Ok, so I can stay with Roger's core + RadioHead for F104C8 for now. ST-LINK reads that I have 128k Flash, even though it's C8 Can I use all 128k memory? If so, I have the perfect platform for my project.
The second option is to use RadioLib + Official Core. I was looking for a solution in the forum and jgromes wrote about it. I checked and examples are compiling for the Official Core for F103C8 and even F401CC which I am waiting for delivery. I just need to learn RadioLib, a new library for me, and I hope it will work with RadioHead;) I have to check all the possibilities and the combination.
I am very excited about STM32 after switching from AVR. This is very evident when using OLED. For AVR this was a challenge, not enough Ram for frame buffering when the program was large, not too fast refresh. STM32 does the same with such lightness, I have to slow down the animation very much In addition, Ram is a lot, I don't even optimize variables;) (I know I should).
stas2z thanks for your help.
--------------------------------------------- EDIT ----------------------------------------
I tested the configuration: blue pill F104C8 + Official Core + RadioLib. The sketch compiles correctly, but the processor "stops" on the command int state = lora.begin (); My next command is digitalWrite (PC13, LOW); and it's never done.
I made another test: Arduino Pro Mini (AVR processor) + RadioLib + sample sketch. I did not connect the RFM95 radio, Arduino itself. The program returned error -2 no radio. It should be. Test passed.
Then I just connected the blue pill, no radio, the same sketch as above. Again, the program stops at int state = lora.begin (); Returns no error via serial port, silence ... Test failed.
This is the sketch from the examples a bit modified by me. The last thing I see via serial port is: [SX1278] Initializing GO !!
I probably make a basic mistake, but I couldn't find the code example for my blue pill.
If anyone has time to look at this, thank you in advance.
The second option is to use RadioLib + Official Core. I was looking for a solution in the forum and jgromes wrote about it. I checked and examples are compiling for the Official Core for F103C8 and even F401CC which I am waiting for delivery. I just need to learn RadioLib, a new library for me, and I hope it will work with RadioHead;) I have to check all the possibilities and the combination.
I am very excited about STM32 after switching from AVR. This is very evident when using OLED. For AVR this was a challenge, not enough Ram for frame buffering when the program was large, not too fast refresh. STM32 does the same with such lightness, I have to slow down the animation very much In addition, Ram is a lot, I don't even optimize variables;) (I know I should).
stas2z thanks for your help.
--------------------------------------------- EDIT ----------------------------------------
I tested the configuration: blue pill F104C8 + Official Core + RadioLib. The sketch compiles correctly, but the processor "stops" on the command int state = lora.begin (); My next command is digitalWrite (PC13, LOW); and it's never done.
I made another test: Arduino Pro Mini (AVR processor) + RadioLib + sample sketch. I did not connect the RFM95 radio, Arduino itself. The program returned error -2 no radio. It should be. Test passed.
Then I just connected the blue pill, no radio, the same sketch as above. Again, the program stops at int state = lora.begin (); Returns no error via serial port, silence ... Test failed.
This is the sketch from the examples a bit modified by me. The last thing I see via serial port is: [SX1278] Initializing GO !!
Code: Select all
/*
RadioLib SX127x Receive with Interrupts Example
This example listens for LoRa transmissions and tries to
receive them. Once a packet is received, an interrupt is
triggered. To successfully receive data, the following
settings have to be the same on both transmitter
and receiver:
- carrier frequency
- bandwidth
- spreading factor
- coding rate
- sync word
Other modules from SX127x/RFM9x family can also be used.
For full API reference, see the GitHub Pages
https://jgromes.github.io/RadioLib/
*/
// include the library
#include <RadioLib.h>
// SX1278 has the following connections:
// NSS pin: 10
// DIO0 pin: 2
// RESET pin: 9
// DIO1 pin: 3
SX1278 lora = new Module(PA0, PA1, PA2, PA3);
// or using RadioShield
// https://github.com/jgromes/RadioShield
//SX1278 lora = RadioShield.ModuleA;
void setup() {
Serial.begin(9600);
pinMode(PC13, OUTPUT);
// initialize SX1278 with default settings
Serial.print(F("[SX1278] Initializing ... "));
// carrier frequency: 434.0 MHz
// bandwidth: 125.0 kHz
// spreading factor: 9
// coding rate: 7
// sync word: 0x12
// output power: 17 dBm
// current limit: 100 mA
// preamble length: 8 symbols
// amplifier gain: 0 (automatic gain control)
digitalWrite(PC13, LOW);
Serial.println(F("[SX1278] Initializing 3 "));
delay(1000); digitalWrite(PC13, HIGH);
Serial.println(F("[SX1278] Initializing 2 "));
delay(1000); digitalWrite(PC13, LOW);
Serial.println(F("[SX1278] Initializing 1 "));
delay(1000); digitalWrite(PC13, HIGH);
Serial.println(F("[SX1278] Initializing GO!! "));
int state = lora.begin();
digitalWrite(PC13, LOW);
if (state == ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while (true);
}
digitalWrite(PC13, LOW);
// set the function that will be called
// when new packet is received
lora.setDio0Action(setFlag);
// start listening for LoRa packets
Serial.print(F("[SX1278] Starting to listen ... "));
state = lora.startReceive();
if (state == ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while (true);
}
// if needed, 'listen' mode can be disabled by calling
// any of the following methods:
//
// lora.standby()
// lora.sleep()
// lora.transmit();
// lora.receive();
// lora.readData();
// lora.scanChannel();
}
// flag to indicate that a packet was received
volatile bool receivedFlag = false;
// disable interrupt when it's not needed
volatile bool enableInterrupt = true;
// this function is called when a complete packet
// is received by the module
// IMPORTANT: this function MUST be 'void' type
// and MUST NOT have any arguments!
void setFlag(void) {
// check if the interrupt is enabled
if(!enableInterrupt) {
return;
}
// we got a packet, set the flag
receivedFlag = true;
}
void loop() {
// check if the flag is set
if(receivedFlag) {
// disable the interrupt service routine while
// processing the data
enableInterrupt = false;
// reset flag
receivedFlag = false;
// you can read received data as an Arduino String
String str;
int state = lora.readData(str);
// you can also read received data as byte array
/*
byte byteArr[8];
int state = lora.readData(byteArr, 8);
*/
if (state == ERR_NONE) {
// packet was successfully received
Serial.println(F("[SX1278] Received packet!"));
// print data of the packet
Serial.print(F("[SX1278] Data:\t\t"));
Serial.println(str);
// print RSSI (Received Signal Strength Indicator)
Serial.print(F("[SX1278] RSSI:\t\t"));
Serial.print(lora.getRSSI());
Serial.println(F(" dBm"));
// print SNR (Signal-to-Noise Ratio)
Serial.print(F("[SX1278] SNR:\t\t"));
Serial.print(lora.getSNR());
Serial.println(F(" dB"));
// print frequency error
Serial.print(F("[SX1278] Frequency error:\t"));
Serial.print(lora.getFrequencyError());
Serial.println(F(" Hz"));
} else if (state == ERR_CRC_MISMATCH) {
// packet was received, but is malformed
Serial.println(F("[SX1278] CRC error!"));
} else {
// some other error occurred
Serial.print(F("[SX1278] Failed, code "));
Serial.println(state);
}
// put module back to listen mode
lora.startReceive();
// we're ready to receive more packets,
// enable interrupt service routine
enableInterrupt = true;
}
}
If anyone has time to look at this, thank you in advance.