Markus_L811
Well-known member
Hello,
I have enabled an trigger event on UART0_S2, the UART_S2_LBKDE Flag, so I attached my ISR routine to it, when the Flag is fired the IRQ_UART0_STATUS does nothing. Even there is nothing inside the ISR routine he should jump in it, it look like IRQ_UART0_STATUS don't look inside UART0_S2.
Simpified Sketch
Output
Any advice to it? May my I made some mistakes.
I have enabled an trigger event on UART0_S2, the UART_S2_LBKDE Flag, so I attached my ISR routine to it, when the Flag is fired the IRQ_UART0_STATUS does nothing. Even there is nothing inside the ISR routine he should jump in it, it look like IRQ_UART0_STATUS don't look inside UART0_S2.
Simpified Sketch
Code:
#define PRINTBIN(Num) for (uint32_t t = (1UL<< (sizeof(Num)*8)-1); t; t >>= 1) Serial.write(Num & t ? '1' : '0'); // Prints a binary number with leading zeros (Automatic Handling)
//Lin Initailisation
#define linspeed 19200
int activeBufIndex;
uint8_t *activeBuf;
constexpr int max_LinBUS_Datasize = 10;
int pointer = 0;
void uart0isr_status() {
UART0_S2 |= UART_S2_LBKDIF;
UART0_S2 |= UART_S2_RXEDGIF;
pointer++;
}
void uart0isr_error() {
UART0_S1 &= ~UART_S1_OR;
pointer++;
}
void setup() {
Serial.begin(115200);
pinMode(19, OUTPUT);
LinBUS_begin();
}
void loop() {
Serial.print("UART0_S1 ");
PRINTBIN(UART0_S1);
Serial.print(" UART0_S2 ");
PRINTBIN(UART0_S2);
Serial.println();
Serial.println(pointer);
delay(250);
}
void LinBUS_begin(void) {
Serial1.begin(linspeed);
attachInterruptVector(IRQ_UART0_STATUS, uart0isr_status);
attachInterruptVector(IRQ_UART0_ERROR, uart0isr_error);
// We fill bytes from the buffer in the framing error ISR, so we
// can set to the same priority.
NVIC_SET_PRIORITY(IRQ_UART0_ERROR, NVIC_GET_PRIORITY(IRQ_UART0_STATUS));
//UART0_S2 &= ~UART_S2_RXINV;
//UART0_C1 |= UART_C1_M;
//UART0_C4 &= ~UART_C4_M10;
//UART0_C1 |= UART_C1_PE;
// Enable LinBreakdetection on UART0
UART0_S2 |= UART_S2_LBKDE;
NVIC_ENABLE_IRQ(IRQ_UART0_STATUS);
// Enable UART0 interrupt on frame error
//UART0_C3 |= UART_C3_FEIE;
//UART0_C3 |= UART_C3_ORIE;
NVIC_ENABLE_IRQ(IRQ_UART0_ERROR);
}
Output
Code:
12:11:55.173 -> UART0_S1 11000000 UART0_S2 00000010
12:11:55.173 -> 0
12:11:55.173 -> UART0_S1 11000000 UART0_S2 00000010
12:11:55.173 -> 0
12:11:55.173 -> UART0_S1 11000000 UART0_S2 00000010
12:11:55.173 -> 0
12:11:55.173 -> UART0_S1 11000000 UART0_S2 00000010
12:11:55.173 -> 0
12:11:55.173 -> UART0_S1 11000000 UART0_S2 00000010
12:11:55.173 -> 0
12:11:55.173 -> UART0_S1 11000000 UART0_S2 00000010
12:11:55.173 -> 0
12:11:55.173 -> UART0_S1 11000000 UART0_S2 00000010
12:11:55.173 -> 0
12:11:55.405 -> UART0_S1 11000000 UART0_S2 00000010
12:11:55.405 -> 0
12:11:55.675 -> UART0_S1 11000000 UART0_S2 00000010
12:11:55.675 -> 0
12:11:55.929 -> UART0_S1 11001000 UART0_S2 11000010
12:11:55.929 -> 0
12:11:56.176 -> UART0_S1 11001000 UART0_S2 11000010
12:11:56.176 -> 0
12:11:56.430 -> UART0_S1 11001000 UART0_S2 11000010
12:11:56.430 -> 0
12:11:56.678 -> UART0_S1 11001000 UART0_S2 11000010
Any advice to it? May my I made some mistakes.
Last edited: