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.
10 years, 5 months ago.
Can I use interrupts while working with the USBSerial?
Hello! I am working with the FRDMKL25Z.
I tryed to use the following code to test if the timer interrupts works when I use the USBSerial class. The result is that ticker locks the code every timer overflows... why does that happen?
#include "mbed.h"
#include "USBSerial.h"
/*---Classes------*/
DigitalOut myled(LED1);
DigitalOut pte1(PTE1);
USBSerial pc;
Ticker t1;
/*---Functions---*/
void SerialCallback(void);
void T1Handler(void);
int main() {
pc.attach(&SerialCallback);
t1.attach(&T1Handler,1);
while(1) {
myled=1;
wait(1);
myled=0;
wait(1);
}
}
void SerialCallback(void){
while(pc.readable()){
pc._putc(pc._getc());
}
return;
}
void T1Handler(void){
pc._putc(0x32);
return;
}
OF COURSE! you cant use those functions inside an interrupt!!!
posted by Thiago . 25 Jun 2015