Arduino IDE 2.x (2.2)

Development environment specific, Arduino, Eclipse, VS2013, Em::Blocks etc
Post Reply
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Arduino IDE 2.x (2.2)

Post by ag123 »

Tried out the current version of Arduino IDE 2.2.1 and with STM core (2.6.0)
https://www.arduino.cc/en/software
Apparently, it is working quite well now
Arduino IDE 2.2
Arduino IDE 2.2
ide2.2.png (34.13 KiB) Viewed 7089 times
but that is just initial impressions, have not tried debug etc.

One of the features reference jumps for symbols, works to an extent but imperfect.
for some of the symbols, you can right click select Goto Definition and it would open the include / definition in a new tab.
It is one of the 'missing' features, which accordingly is provided by the clangd https://clangd.llvm.org/.
Some of the reference jumps don't work, but it compiles fine.

The screen print and console response messages is a 'blinky' app, which prints something to usb serial periodically.
it is more of a lousy 'breathing' led test. the sample sketch:

Code: Select all

#include <Arduino.h>
#include <HardwareTimer.h>

HardwareTimer *pTimer2 = new HardwareTimer(TIM2);

int16_t count;
int8_t dir;
bool pr = false;

void ledon() {
	int8_t channel = 1;
	digitalWrite(LED_BUILTIN, LOW);
	if(count > 100) {
		dir = -1;
		count = 100;
	} else if (count < 1) {
		dir = 1;
		count = 1;
		pr = true;
	}
	pTimer2->setCaptureCompare(channel, count, PERCENT_COMPARE_FORMAT); // count here is the duty cycle 1-100
}

void ledoff() {
	digitalWrite(LED_BUILTIN, HIGH);
	count += dir;
}

void setup() {
	count = 0;
	dir = 1;

	Serial.begin();
	pinMode(LED_BUILTIN, OUTPUT);
	digitalWrite(LED_BUILTIN, LOW);

	uint8_t channel = 1;
	pTimer2->pause(); // pause the timer
	pTimer2->setMode(channel, TIMER_OUTPUT_COMPARE_PWM1); //output compare mode, got this from reading the api notes
	pTimer2->setOverflow(50, HERTZ_FORMAT); // call back at 50 hz
	pTimer2->attachInterrupt(ledon); // attach ledon() every cycle turn on the led
	pTimer2->attachInterrupt(channel, ledoff); // attach ledoff() end of duty cycle turn off the led
	pTimer2->refresh(); //reset the counters
	pTimer2->resume();

}

void loop() {
  if(pr) {
    Serial.println("hello stm32");
    pr = false;
  }
  delay(1000);
}
as usual for those who need usb-serial, select USB Support ( CDC generic 'Serial' supercede u(s)art ) from the menu
BennehBoy
Posts: 135
Joined: Sat Jan 04, 2020 2:38 am
Answers: 1

Re: Arduino IDE 2.x (2.2)

Post by BennehBoy »

Debug works fine as long as you edit the openocd.cfg supplied with the core release - change "reset_config srst_nogate" to "reset_config none"
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Arduino IDE 2.x (2.2)

Post by ag123 »

slightly improved 'breathing led', this one uses floating point
so use an F4xx or one that has FPU enabled.
that square root function gives roughly a cosine or unit circle function.

Code: Select all

#include <Arduino.h>
#include <HardwareTimer.h>
#include <math.h>

HardwareTimer *pTimer2 = new HardwareTimer(TIM2);

int16_t count;
int8_t dir;
bool pr = false;

void ledon() {
	int8_t channel = 1;
	digitalWrite(LED_BUILTIN, HIGH);
	if(count > 199) {
		dir = -1;
		count = 199;
	} else if (count < 1) {
		dir = 1;
		count = 1;
		pr = true;
	}
	float x = ((float) count)/200.0F;
	int dutycycle = sqrt(1 - x * x) * 100;

	pTimer2->setCaptureCompare(channel, dutycycle, PERCENT_COMPARE_FORMAT); // count here is the duty cycle 1-100
}

void ledoff() {
	digitalWrite(LED_BUILTIN, LOW);
	count += dir;
}

void setup() {
	count = 0;
	dir = 1;

  Serial.begin();
	pinMode(LED_BUILTIN, OUTPUT);
	digitalWrite(LED_BUILTIN, LOW);

	uint8_t channel = 1;
	pTimer2->pause(); // pause the timer
	pTimer2->setMode(channel, TIMER_OUTPUT_COMPARE_PWM1); //output compare mode, got this from reading the api notes
	pTimer2->setOverflow(50, HERTZ_FORMAT); // call back at 50 hz
	pTimer2->attachInterrupt(ledon); // attach ledon() every cycle turn on the led
	pTimer2->attachInterrupt(channel, ledoff); // attach ledoff() end of duty cycle turn off the led
	pTimer2->refresh(); //reset the counters
	pTimer2->resume();

}

void loop() {
  if(pr) {
    Serial.println("hello stm32");
    pr = false;
  }
	delay(1000);
}

dannyf
Posts: 447
Joined: Sat Jul 04, 2020 7:46 pm

Re: Arduino IDE 2.x (2.2)

Post by dannyf »

I often use two timer ISRs that flip the led pin at slightly different intervals. This leads to the duty cycle on the led goes up and down gradually.

the output compare interrupts are best for this.
bobihot
Posts: 3
Joined: Sun Apr 12, 2020 7:30 am

Re: Arduino IDE 2.x (2.2)

Post by bobihot »

I was project with 2.6.0 and compiles well. Today Arduino IDE 2.2.1 was self updating with 2.7.0 and began give error with Serial2

c:/users/stv/appdata/local/arduino15/packages/stmicroelectronics/tools/xpack-arm-none-eabi-gcc/12.2.1-1.2/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\Stv\AppData\Local\Temp\arduino\sketches\1B21512BF610B2AC24992B858C62C89A\sketch\MultiSerial32.ino.cpp.o: in function `setup':
MultiSerial32.ino.cpp:(.text.setup+0x24): undefined reference to `Serial2'
c:/users/stv/appdata/local/arduino15/packages/stmicroelectronics/tools/xpack-arm-none-eabi-gcc/12.2.1-1.2/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\Stv\AppData\Local\Temp\arduino\sketches\1B21512BF610B2AC24992B858C62C89A\sketch\MultiSerial32.ino.cpp.o: in function `loop':
MultiSerial32.ino.cpp:(.text.loop+0x40): undefined reference to `Serial2'
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1
Attachments
Stm32duinoUSBerr1.png
Stm32duinoUSBerr1.png (38.78 KiB) Viewed 5884 times
Last edited by bobihot on Thu Nov 23, 2023 10:12 am, edited 2 times in total.
MCU Hardware&Software developer. Desktop programing
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Arduino IDE 2.x (2.2)

Post by fpiSTM »

Without more info hard to help. Which board? Options selected? Sketch?....
bobihot
Posts: 3
Joined: Sun Apr 12, 2020 7:30 am

Re: Arduino IDE 2.x (2.2)

Post by bobihot »

This is some changed Example MultiSerial:
/*
Multiple Serial test
-----
https://www.arduino.cc/en/Tutorial/Buil ... SerialMega
*/

void setup() {
// initialize both serial ports:
Serial.begin(9600);
Serial2.begin(2000000);
}

void loop() {
// read from port 1, send to port 0:
if (Serial2.available()) {
int inByte = Serial2.read();
Serial.write(inByte);
}
Serial2.write('A');

// read from port 0, send to port 1:
if (Serial.available()) {
int inByte = Serial.read();
Serial2.write(inByte);
}
delay(100);
}

Board is STM32 bluepill compatible
Stm32duinoSet1.jpg
Stm32duinoSet1.jpg (79.66 KiB) Viewed 5878 times
MCU Hardware&Software developer. Desktop programing
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Arduino IDE 2.x (2.2)

Post by fpiSTM »

Well the issue here is the BP have only one Serial defined by default: Serial1 which is mapped on default instance Serial.
You have to define the Serial2 instance:
https://github.com/stm32duino/Arduino_C ... wareserial
bobihot
Posts: 3
Joined: Sun Apr 12, 2020 7:30 am

Re: Arduino IDE 2.x (2.2)

Post by bobihot »

Thanks,
But this was running before?
MCU Hardware&Software developer. Desktop programing
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Arduino IDE 2.x (2.2)

Post by fpiSTM »

No. You probably used another sketch which defined Serial2
Post Reply

Return to “IDE's”