Page 1 of 1

Arduino IDE 2.x (2.2)

Posted: Thu Oct 19, 2023 12:12 pm
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 11604 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

Re: Arduino IDE 2.x (2.2)

Posted: Thu Oct 19, 2023 9:51 pm
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"

Re: Arduino IDE 2.x (2.2)

Posted: Fri Oct 20, 2023 8:55 am
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);
}


Re: Arduino IDE 2.x (2.2)

Posted: Mon Oct 30, 2023 8:37 pm
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.

Re: Arduino IDE 2.x (2.2)

Posted: Thu Nov 23, 2023 8:55 am
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

Re: Arduino IDE 2.x (2.2)

Posted: Thu Nov 23, 2023 9:04 am
by fpiSTM
Without more info hard to help. Which board? Options selected? Sketch?....

Re: Arduino IDE 2.x (2.2)

Posted: Thu Nov 23, 2023 9:31 am
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 10393 times

Re: Arduino IDE 2.x (2.2)

Posted: Thu Nov 23, 2023 9:58 am
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

Re: Arduino IDE 2.x (2.2)

Posted: Thu Nov 23, 2023 10:14 am
by bobihot
Thanks,
But this was running before?

Re: Arduino IDE 2.x (2.2)

Posted: Thu Nov 23, 2023 10:21 am
by fpiSTM
No. You probably used another sketch which defined Serial2