Should we use detach() of Ticker before use attach_us?

15 Aug 2010

Hi all.

I have a question. Should we use detach() of Ticker before use attach_us?         

Ticker ticker;

ticker.attach_us(this, &Example::tick, 100);
// Something to do.

ticker.attach_us(this, &Example::tick, 200);
// Something to do.
I can't see the c++ source. so I couldn't find the answer. In my case, the code doesn't work correctly. It break another ticker operation. I don't know why the codes makes the result. I'd like to know why.

If we always should be call detach(), Why didn't call the function automatically?

Shin.

15 Aug 2010

I think you should have 2 ticker objects declared. Now you are only changing the interrupt vector of your ticker object two times. So your first ticker wont work anymore.

15 Aug 2010

Dear Mr. Chiristian

Thank you for your reply.

So your first ticker wont work anymore.

Yeah. I knew it. I'd like to change a interval of the ticker dynamically. I think it's not so bad way. And it's simple way to provide the solution.

But thank you for your reply. It's good idea for my question. :)

Regards,

Shin.

16 Aug 2010

I've confirmed that there does appear to be an issue, and I shall investigate shortly.

16 Aug 2010

Dear Mr. Jon-san

Thank your for your support. I just created a test program for this problem.

The program have 2 ticker. One of for LED, and one of for 'do nothing'.

But we can see the result.

http://mbed.org/users/shintamainjp/programs/TestProgramForBugTopic990/latest

Regards,

Shin.

16 Aug 2010

Dear Mr. Jon-san

I found same problem with Timeout. I think the cause is same. I updated my test program. Please setup for a test ...

/**
 * TEST_MODE 0: Test a Timeout.
 * TEST_MODE 1: Test a Ticker.
 */
#define TEST_MODE 0
Regards,

Shin. :)

17 Aug 2010

I am pretty sure the problem lies in the way we handle function pointers (vanilla C functions and C++ pointers to object methods), and this affects all the classes with an attach() method (including Serial, CAN etc.).  I am looking at this at the moment, and hope to have a resolution sooner rather than later.

25 Aug 2010

Dear Mr. Jon san.

Ah... I have no idea how things really are.

Could you tell me current status of it?

Best regards,

Shin :)

25 Aug 2010

I have a fix for this, which is currently being tested along with a couple of other fixes. Hope to release this very shortly.

25 Aug 2010

Dear Mr. Jon san.

Oh.

That's great.

Thank you so much!

I'm going to test it if it released.

Shin :)

26 Aug 2010

There is now a version 25 available which I believe fixes this - could you give it a go?

26 Aug 2010

Dear Mr. Jon san

Thank you for your great works!

I just checked the release.

And I can't find any problem with my test program. :)

Thank you again Mr. Jon san.

Best regards,

Shin.