Giga uses the same STM32H747XI microcontroller found on the Arduino Portenta H7, but the Portenta Timer library doesn't support the Giga board.
Thanks
Giga uses the same STM32H747XI microcontroller found on the Arduino Portenta H7, but the Portenta Timer library doesn't support the Giga board.
Thanks
Cannot comment about Portenta but I can compile interrupt driven code for GIGA. I cannot upload using IDE 2.0.3 under Ubuntu 22.10. (wary about the bug reports on 2.0.4)
Regards.
Thanks for the reply. My Pin interrupts compile (attachInterrupt), but my timer interupt does not compile.
void startTimer() {
cli(); //stop interrupts for till we make the settings
/*1. First we reset the control register to amke sure we start with everything disabled.*/
TCCR1A = 0; // Reset entire TCCR1A to 0
TCCR1B = 0; // Reset entire TCCR1B to 0
/*2. We set the prescalar to the desired value by changing the CS10 CS12 and CS12 bits. */
TCCR1B |= B00000100; //Set CS12 to 1 so we get prescalar 256
/*3. We enable compare match mode on register A*/
TIMSK1 |= B00000010; //Set OCIE1A to 1 so we enable compare match A
/*4. Set the value of register A to 31250*/
OCR1A = 31250; //Finally we set compare register A to this value
sei(); //Enable back the interrupts
}
ISR(TIMER1_COMPA_vect){
TCNT1 = 0; //First, set the timer back to 0 so it resets for next interrupt
panelTimerInterrupt();
}
Hello @simons007,
Sorry for the late response. This stuff is way out of my league. Several years ago I tried to get more stable and longer duration timer code and ran into similar code. Not having any meaningful microcontroller experience I gave up.
I've been digging through STMicroelectronics datasheets. Your sample may help me to follow along in a few months! Thanks for posting it.
Regards.
We can take inspiration from the source "Tone.cpp " to obtain a first solution. The code bellow wait a command type by exemple 100g to start a timer calling a sample counter at the gived frequency.
/*
trial
inspired by "Tone.cpp"
This example code is in the public domain
*/
#include "Arduino.h"
#include "pinDefinitions.h"
#include "mbed.h"
using namespace std::chrono_literals;
using namespace std::chrono;
long visuc = 0, ovisuc, os;
int freq = 1;
int val;
class NSTimer {
mbed::Ticker ticker; // calls a callback repeatedly with a timeout
public:
bool state = false;
void start(int freq) {
ticker.attach(mbed::callback(this, &NSTimer::count), 1000000us / freq );
visuc = 0;
state = true;
}
void count(void) {
//ini=10;
visuc++;
}
void stop(void) {
ticker.detach();
state = false;
}
};
NSTimer timer1;
void setup() {
Serial.begin(9600);
while (!Serial && millis() < 5000);
delay(100);
Serial.println("BONJOUR (setup)");
}
// Task count between call
void loop() {
long s = millis() / 1000;
if (os != s) {
if (visuc != ovisuc) {
Serial.print("counter: "); Serial.println(visuc);
ovisuc = visuc;
}
os = s;
}
if (Serial.available()) {
char c = Serial.read();
if (c == 'd' || c =='g' ) {
if (val == 0) val = 1;
Serial.print("FREQ:"); Serial.println(val);
if (timer1.state) timer1.stop();
timer1.start(val);
val = 0;
}
if (c == 'f' || c =='s' ) timer1.stop();
if (c == 'c') val = 0;
if (c >= '0' && c <= '9' ) {
val = val * 10 + c - '0';
Serial.print("valc:"); Serial.println(val);
}
}
}
cordially,