Running Arduino on the BrainPad

We explain how to run Arduino on the BrainPad, using the Arduino IDE to create a binary file, that can be loaded using STM tools.

Arduino IDE:

STM32 Bootloader documentation:
http://docs.ghielectronics.com/hardware/loaders/stm32_bootloader.html

BrainPad website:

TinyCLR OS:

5 Likes

Are you trying to hunt me from there :smiley:

i didn’t know for Arduino IDE can be used with Nucleo STM32 boards until now.

Instead i used https://developer.mbed.org/
throught - Visual Studio with VisualGDB

so now you make me yet laziest :smiley:
so thanx a lot for INFO “but i still remain .NET Developer” so viva FEZ .

3 Likes

Got the Arduino LED blink example running. But until now no success to read the buttons.
Anybody succeeded?

i tested with Arduino IDE Nucleo STM32F411RET and everything work

TESTED BLINK (throught D13)
TESTED LCD 1602 I2C (throught D14,D15)
TESTED SSD3306 I2C (throught D14,D15)

just keep in mind you can use by name or similiar

Digital:

digitalWrite(33, HIGH); << do not use this way because cause problem

digitalWrite(D33, HIGH);
digitalWrite(PB0, HIGH);
digitalWrite(pinNametoDigitalPin(PB_0), HIGH);

AnalogRead:
analogRead(0); <=== do not use this way because cause problem

analogRead(A0);
analogRead(PA3);
analogRead(pinNametoDigitalPin(PA_3));

AnalogWrite:

analogWrite(A0);
analogWrite(PA3);
analogWrite(pinNametoDigitalPin(PA_3));

i belive brainpad should work well since have similiar to nucleo mcu but just need to now which pins is used for button - leds - temperature sensor - oled and it could used as is with arduino ide too.

1 Like

Thanks. I’ll try in a minute. Do you have UART and SPI working as well? That would be the next steps.

i tried just i2c since it worked well i belive UART “can be checked throught SERIAL MONITOR too”

throught Serial.print(“test test test\n”);

but with SPI i hae no sensor to test it

next test is what i want to do is Wiz5100 Ethernet “it work with SPI” if it work that mean SPI work or MFRC522 RFID it work with SPI too :smiley:

Still no luck with reading the buttons. Here is the Schematic:

http://files.ghielectronics.com/downloads/Schematics/FEZ/BrainPad%20BP2%20Schematic.pdf

Here is the code:
The LEDs should blink red or blue depending on the button state

int state = LOW;
void setup()
{
// initialize digital pin as an output.
pinMode(pinNametoDigitalPin(PC6), OUTPUT); // Blue
pinMode(pinNametoDigitalPin(PC9), OUTPUT); // Red

pinMode(pinNametoDigitalPin(PA5), INPUT);
// Edit: this was wrong, must be:
//pinMode(pinNametoDigitalPin(PA5), INPUT_PULLUP);
}

void loop()
{
state = digitalRead(pinNametoDigitalPin(PA5));
if (state == HIGH)
{
digitalWrite(pinNametoDigitalPin(PC9), HIGH); // turn the red LED on
delay(100); // wait for a time
digitalWrite(pinNametoDigitalPin(PC9), LOW); // turn the red LED off
delay(100); // wait for a time
}
else
{
digitalWrite(pinNametoDigitalPin(PC6), HIGH); // turn the blue LED on
delay(100); // wait for a time
digitalWrite(pinNametoDigitalPin(PC6), LOW); // turn the blue LED off
delay(100); // wait for a time
}
}

I got it !
The button must be declared as:

pinMode(pinNametoDigitalPin(PA5), INPUT_PULLUP);

Now it works.

4 Likes

The next point is serial (UART) connection. Is there a way to use a virtual USB serial driver as with a regular Arduino board?

Yes you can do similiar to Arduino without any change

void setup()
{
Serial2.begin(9600);
}

void loop()
{
Serial2.print(" Hello World");
}

On STM32F401/411 :

Stm Uart1 (pa2,pa3) = Arduino Serial
Stm Uart2 (pa9,pa10)= Arduino Serial1
Stm Uart6 (pa11,pa12 also as usb otg)= Arduino Serial2
But for upload direkt should be used Uart1

Under Menu on Arduino Ide set Serial to All

Or Connect pa2/pa3 ,gnd and vcc to any usb uart

@RoSchmi
P.S.
Forgot one thing Arduino IDE should show like a mass storage or ST Link device for upload after compile otherwise minitoring uart should work :slight_smile:

Partial success: I can now use Serial.println to get messages from the BrainPad through a GHI Rs232 Module to the Serial Port of my PC.
The RS232 Module is connected to PA2 of the BrainPad as TX (Expansion Header Pin 15 (INT).

void setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.println(“test test test\r\n”);
delay(1000);
}

However, if I activate in the Arduino IDE Tools -> Other Serial Instance: ALL or Serial1(if available) or Serial2(if available)
I get a compiler error:

Arduino: 1.8.3 (Windows 10), Board: “Nucleo-64, Nucleo F401RE, Mass Storage, All, None”

arm-none-eabi-gcc: error: C:\Users\Roland\AppData\Local\Temp\arduino_build_963841/…\arduino_cache_729421\core\core_STM32_stm32_Nucleo_64_board_part_num_NUCLEO_F401RE,
upload_method_MassStorageMethod,Other_serial_enable_SerialAll,USB_interface_enable_USB_ba6ca7138be2b72e751689a40e15ca39.a:
No such file or directory

exit status 1
Fehler beim Kompilieren fĂĽr das Board Nucleo-64.

Next step is to control the display.
Would be nice to get some information from GHI.

There is a whole tech talk about this display. The very first tech talk

Thanks, I will have a look on it tomorrow.

Tried to adapt the Adafruit Adafruit_SSD1306 I2C library for the STM32F401 Mainboard, but no success.
The BrainPad display works fine on an Arduino Pro mini with the Adafruit library.
Does anybody have an Arduino library that works on the STM32F401 Mainboard?

@RoSchmi

you need to modify file variant.h on

C:\Users\USERNAME\AppData\Local\arduino15\packages\STM32\hardware\stm32\2017.8.4\variants\NUCLEO_F401RE\

i done for you so you need to just replace this file with installed ones
(i put an arduino sample,modified file variant.h ,ssd1306 library for arduino,also compiled firmware) just donwload from [CLIK TO DOWNLOAD THERE]
(https://drive.google.com/drive/folders/0B5LeqLuG9sGGd0dJVEd1c21ENDg?usp=sharing)

1 Like

Still no success. Is it correct, that only variant.h must be exchanged and not the entire NUCLEO_401RE folder?

Yes only variant.h

Hmm, the oled on the new BrainPad seems to be a 128x32 display (on an Arduino Pro Mini it works with this configuration). Your example was for a 128x64 display. Did you get it working on the new BrainPad or on a Nucleo-401RE board? Could you please send me a copy of your …\variants\NUCLEO_F401RE folder? If this doesn’t help, I would have to search systematically for the reason.

Still not received brainpad but
NUCLEO 411 yes

But i test a lot of app with Arduino Ide
and Nucleo Stm32f411 (401 is little lite on speed and ram than 411 otherwiese are same)