You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Problem with using interrupt on Kit_XMC14_2Go #429
I am using the Kit_XMC14_2Go to talk to some sensor IC via SPI. To initiate the SPI sequence, the controller is instructed to wait for a pin to go low. I am intending to solve this with an interrupt. However, the implemented solution in Arduino is not working.
After executing the command
attachInterrupt(digitalPinToInterrupt(9), measurementCompleteISR, FALLING);
the subsequent execution of the remaining code is stopped.
Checking the github, I saw that you implemented the attachInterrupt command for the XMC1400. Do you have a minimal working example for this board using an external interrupt? I could not identify one from the available examples. I assume that only pin 9 or P1.4 is capable of producing such an interrupt.
I saw the section on readthedocs talking about using interrupt 0 instead of 1 to prevent problems with the serial communication, but the attachInterrupt command should use interrupt 0 anyways to my understanding.
I am using the Arduino IDE in version 2.3.7 and the release 4.0.1 from this repo.
Thank you for the detailed description and code. We are currently reviewing the behavior you're experiencing with the attachInterrupt() implementation.
In the meantime, as a temporary solution, please try reordering your Serial.begin() initialization after calling attachInterrupt() in the setup function.
we will investigate this and work towards a better solution.
void setup() {
// Configure necessary pins
pinMode(14, OUTPUT);
pinMode(PIN_CS, OUTPUT);
digitalWrite(PIN_CS, HIGH);
pinMode(PIN_READSTATE, INPUT);
// Initialize SPI
SPI.begin();
delay(5);
SPI.beginTransaction(spiSettings);
// Configure the interrupt on PIN_READSTATE (e.g., PIN 9 / P1.4)
attachInterrupt(digitalPinToInterrupt(PIN_READSTATE), measurementCompleteISR, FALLING);
// Initialize Serial AFTER configuring the interrupt
Serial.begin(500000);
while (!Serial) {;} // Wait for Serial communication to establish
Serial.println("Start");
Serial.println("Interrupt configured on pin 9 (P1.4) for FALLING edge");
}
Hi, the interrupt now works without a problem. Thank you for looking into and solving it.
However, the updated version 4.1.0 did not show up automatically in the boards manager menu. The latest version there is 3.5.5. I am not sure how this synchronises, but maybe worth an investigation. I had to do a manual update.
Activity
ederjc commentedon Feb 19, 2026
Hi @integratedjoy,
We assume you are using
Serial.println('...')after attaching the interrupt and this doesn't print anything. Is that correct?As a quick workaround, can you try calling
Serial.begin(...)after attaching the interrupt and then trySerial.println('...')again?Also, it would be great if you could share your code or the relevant part, so we can reproduce the error better.
Thanks!
Julian
integratedjoy commentedon Feb 19, 2026
Hi Julian,
it is not only about the Serial Write but the code execution in general.
I attached the file.
#include <SPI.h>
// ===== SPI CONFIG ===== for XMC14 KIT2GO
#define SPI_SPEED 1000000
#define PIN_CS 3
#define CONST_DELAY 10
const uint8_t PIN_READSTATE = 9; // Pin 9 = P1.4
// ===== Register Addresses =====
enum {
REG_READ = 0x00,
REG_CFG1 = 0x01,
REG_CFG2 = 0x02,
REG_CFG3 = 0x03,
REG_CFG4 = 0x04,
REG_START = 0x05
};
// ===== SPI MODE1: CPOL=0, CPHA=1 =====
SPISettings spiSettings(SPI_SPEED, MSBFIRST, SPI_MODE1);
// Interrupt flag
volatile bool measComplete = false;
uint16_t makeFrame(uint8_t rw, uint8_t addr, uint16_t data12);
void CMUT_Write_Register(uint8_t adr, uint16_t data);
uint16_t CMUT_SPI_Transaction(uint16_t frame);
// Interrupt callback function
void measurementCompleteISR() {
measComplete = true;
}
void setup() {
Serial.begin(500000);
while (!Serial) {;}
Serial.println("Start");
pinMode(14, OUTPUT);
pinMode(PIN_CS, OUTPUT);
digitalWrite(PIN_CS, HIGH);
pinMode(PIN_READSTATE, INPUT);
SPI.begin();
delay(5);
SPI.beginTransaction(spiSettings);
attachInterrupt(digitalPinToInterrupt(PIN_READSTATE), measurementCompleteISR, FALLING);
Serial.println("Interrupt configured on pin 9 (P1.4) for FALLING edge");
CMUT_Write_Register(REG_CFG1, 0x06F3);
delayMicroseconds(CONST_DELAY);
CMUT_Write_Register(REG_CFG3, 0x0001);
delayMicroseconds(CONST_DELAY);
Serial.println("CMUT2 Test - Interrupt Mode");
}
void loop() {
if (measComplete) {
measComplete = false;
}
}
uint16_t makeFrame(uint8_t rw, uint8_t addr, uint16_t data12) {
return (uint16_t)(((rw & 0x1) << 15) | ((addr & 0x7) << 12) | (data12 & 0x0FFF));
}
uint16_t CMUT_SPI_Transaction(uint16_t frame) {
digitalWrite(PIN_CS, LOW);
delayMicroseconds(CONST_DELAY);
SPI.transfer((uint8_t)(frame >> 8));
SPI.transfer((uint8_t)(frame & 0xFF));
delayMicroseconds(CONST_DELAY);
digitalWrite(PIN_CS, HIGH);
return 0;
}
void CMUT_Write_Register(uint8_t adr, uint16_t data) {
CMUT_SPI_Transaction(makeFrame(1, adr, data));
}
dineshgit411 commentedon Feb 20, 2026
Hi @integratedjoy
Thank you for the detailed description and code. We are currently reviewing the behavior you're experiencing with the
attachInterrupt()implementation.In the meantime, as a temporary solution, please try reordering your
Serial.begin()initialization after callingattachInterrupt()in the setup function.we will investigate this and work towards a better solution.
ederjc commentedon Feb 23, 2026
@integratedjoy,
@dineshgit411 is working on PR #430 to fix this issue, I will let you know once the fix is released.
Thanks for reporting the issue!
Julian
ederjc commentedon Mar 4, 2026
Issue resolved and released in https://github.com/Infineon/XMC-for-Arduino/releases/tag/4.1.0
integratedjoy commentedon Mar 4, 2026
just a quick follow-up, pin 9 does now support interrupts?
dineshgit411 commentedon Mar 4, 2026
Hi @integratedjoy yes it will support now. please check now and let us know anything you need support in this.
integratedjoy commentedon Mar 9, 2026
Hi, the interrupt now works without a problem. Thank you for looking into and solving it.
However, the updated version 4.1.0 did not show up automatically in the boards manager menu. The latest version there is 3.5.5. I am not sure how this synchronises, but maybe worth an investigation. I had to do a manual update.
dineshgit411 commentedon Mar 9, 2026
Hi @integratedjoy Thank you for let us know.
please update your board manager url link https://xmc-arduino.readthedocs.io/en/latest/installation-instructions.html
Kindly refer this link
integratedjoy commentedon Mar 9, 2026
works great now