attach how it work

31 Jan 2012

Hello, I need to understands how it works a serial.attach. For exemple I have a module gsm and he send 5 characteres. the first char active my interrupt (.attach) the Mbed makes a jump to the funtion and I execute some code. but in de midlle of execution (function of attach) arrived the second char. What´s append? I terminate the function of .attach "interrupt" or mbed restart the interrupted and i lost the execution of first char? many thanks from Portugal.

void comm(){ pc.putc(gsm.getc()); ...my code;}

int main(){

gsm.attach(&comm, Serial::RxIrq); while (1){ ....normal code}}

31 Jan 2012

Hello Nelson, now I am working with rotary encoders where I use myEncoder.attach(&encoder_interrupt); in main function too.

In the comment from authors of library about this .attach() class member i found this:

"Attach a function to be called when the shaft is rotaded. Keep this function short, as no interrrupts can occour within"

So I understand that called function have to be short as much that will be executed before next interrupt can occur.

01 Feb 2012

I read that UART Buffer is 16 Bytes. The next interrupt (attach) is genereted after read the first buffer? Thanks