any time i try to set an IRQ, the board crashes. comment out the IRQ assignment and it runs like a champ, albeit without interrupts. any help is appreciated.
if the NVIC_EnableIRQ is after the TIM_CR1_CEN, then it hangs on the NVIC assignment. as below, it hangs on the TIM_CR1_CEN.
what am i not getting?
void setup() {
// put your setup code here, to run once:
//Initialize serial and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect.
}
Serial.println("Setting up TIM2");
RCC->APB1ENR |= RCC_APB1ENR_TIM2EN;
TIM2->SR = 0; // Clear status register flags
TIM2->PSC = 2000; // Set prescaler
TIM2->ARR = 36000; // set auto-reload register
TIM2->DIER = TIM_DIER_UIE; // update interrupt
Serial.println("Enabling TIM2 IRQ");
NVIC_SetPriority(TIM2_IRQn, 0);
//NVIC_EnableIRQ(TIM2_IRQn);
Serial.println("Enabling TIM2");
TIM2->CR1 |= TIM_CR1_CEN; // set control register 1 enable flag
Serial.println(TIM2->SR, BIN);
Serial.println("TIM2 setup complete");
Serial.println(TIM2->SR, BIN);
pinMode(13, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
//Serial.println(TIM2->CNT);
if (TIM2->CNT == 35000)
digitalWrite(13, HIGH);
if (TIM2->CNT == 36000)
digitalWrite(13, LOW);
}
void TM2_IRQHandler(void)
{
if(TIM2->SR & TIM_SR_UIF) // if UIF flag is set
{
TIM2->SR &= ~TIM_SR_UIF; // clear UIF flag
Serial.println("TM3 Interrupt");
}
}
We also have the old repo / core based on the original Leaflabs LibMaple code.
This also has support for the Nucleo F103RB bit not the L476 nucleo etc
https://github.com/rogerclarkmelbourne/Arduino_STM32
But the LibMaple based repo does not use HAL, its a clean room implementation by Leaflabs because of licence restrictions when they wrote it in 2012
Anyway, if there is a bug in the Official STM core, you really need to log it as a bug in GitHub, or possibly post to one of the threads on this forum dedicated to that core.
This is the best thread to post to
viewtopic.php?f=48&t=1413&start=50
Because its monitored by Wi6Labs who actually wrote the code for STM
Does the same code compiled and run in another enviromment than the Arduino core and Arduino IDE?
void blink(timer_id_e timer, uint32_t counter) {
digitalWrite(13, !digitalRead(PB1));
}
void setup() {
pinMode(13, OUTPUT);
TimerPulseInit(TIM2_E, 36000, 1000, blink);
}
void blink(timer_id_e timer, uint32_t counter) {
digitalWrite(13, !digitalRead(PB1));
}
void setup() {
pinMode(13, OUTPUT);
TimerPulseInit(TIM2_E, 36000, 1000, blink);
}