Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 3 months ago. This question has been closed. Reason: Off Topic
Second serial port :Not call Interrupt Handler
I try two serial Port on Nucleo F401 Board. I want to test Receive Midi Serial data by intHandler that write it to RingBuffer ,Transmit it by PC serial. But not work it. It seems not call my_inthandler. led is always on.....Why not?
pc.printf Hello is only working.
Sorry ++) Now It work well. Midi Photo Cuppler Device is damaged. This Program is fine.
#include "mbed.h" #include "RawSerial.h" DigitalOut myled(LED1); RawSerial pc(USBTX, USBRX); // tx, rx USART2 RawSerial midi(PA_9, PA_10); // tx, rx USART1 //RawSerial midi(PB_6, PB_7); // tx, rx USART1 uint8_t rxbuffer[256]; uint8_t *rdptr; uint8_t *wrptr; void my_inthandler(void){ myled = 0; while (USART1->SR & (1<<5)){ // RXNE 1: Received data is ready to be read. *wrptr++ = (uint8_t)(USART1->DR & 0xFF); if (wrptr >&rxbuffer[255]) wrptr = &rxbuffer[0];// } } int main() { rdptr = wrptr = &rxbuffer[0]; pc.printf("Hello \n\r"); midi.attach(my_inthandler, Serial::RxIrq); midi.format(8,RawSerial::None,1); midi.baud(31250); myled = 1; // LED is ON while(1) { if(rdptr != wrptr){ pc.printf("%2x\n\r",*rdptr); if (++rdptr >&rxbuffer[255]) rdptr = &rxbuffer[0];// }else{ wait_ms(100); } } }
use "
<<code>> <</code>>
" for code snippets ;)I'll paste here the code from miditest: