Page 1 of 1

Arduino Libraries incorrectly working on STM32F401RE

Posted: Fri May 22, 2020 4:32 pm
by AzizulHaque
Hello,

I am doing a project with the ADS1292R ECG breakout board (https://github.com/Protocentral/ADS1292rShield_Breakout) . The script connects to the ADS1292R shield, reads the data then sends data over serial for the PC to analyse. Works fine, I get a nice waveform on the PC. I installed the STM32 boards to the Arduino IDE, GPIO on and off works fine no issues. but when I load the same code to the STM32F401RE it compiles. but the waveform is incorrect. looks like corrupted data.

Any idea why?

Re: Arduino Libraries incorrectly working on STM32F401RE

Posted: Sat May 23, 2020 2:20 am
by mrburnette
Need more info from you:
- What version of the STM32duino core are you using?
- What OS are you using, Windows 32-bit, Windows 64-bit, iOS, Linux 32/64-bit?
- What warnings are you getting (you have warnings enabled)?
- Which Ardhino board did you test to get a successful trial?
- Assuming you are stacking the Shield onto the F401RE as stated:
Connect the ECG/Respiration shield to the Arduino by stacking it on top of your Arduino. This shield uses the SPI interface to communicate with the Arduino. Since this includes the ICSP header, which is used on newer Arduinos for SPI communication, this shield is also compatible newer Arduino boards such as the Arduino Yun and Due.
Could be something in the library presumption that the shield will be used on an 8-bit Arduino instead of a 32-bit Arduino; that is, int could be cast wrong: 16-bit verses 32-bit. More often than not, library authors make incorrect assumptions on the hardware or do not update the library to include newer hardware: then default to values that are incorrect.

Library authors of AVR and ARM common codebase often do as this Adafruit Example:

Code: Select all

#ifdef __arm__
// should use uinstd.h to define sbrk but Due causes a conflict
extern "C" char* sbrk(int incr);
#else  // __ARM__
extern char *__brkval;
#endif  // __arm__
 
int freeMemory() {
  char top;
#ifdef __arm__
  return &top - reinterpret_cast<char*>(sbrk(0));
#elif defined(CORE_TEENSY) || (ARDUINO > 103 && ARDUINO != 151)
  return &top - __brkval;
#else  // __arm__
  return __brkval ? &top - __brkval : &top - __malloc_heap_start;
#endif  // __arm__
}
Such tests are not made in the library you're using (just did a very quick review, may have missed something.)

Board looks fully supported fully on status page

Code: Select all

Status	Device(s)	Name	Release	Notes
green	STM32F401RE	Nucleo F401RE	0.2.1	

Ray