Search found 4 matches

by MathiasP
Fri Jul 12, 2013 1:19 pm
Forum: General Support
Topic: Memory allocation for C++ classes
Replies: 2
Views: 2865

Re: Memory allocation for C++ classes

Hi Giovanni,

thank you for your suggestion, overriding new works fine (why didn't I to hit on this idea) ...

void* operator new (size_t size)
{
void *p = chCoreAlloc(sizeof(CanProtocol));
return p;
}

Meanwhile I found another solution: placement new
I looks like this:

#include <new ...
by MathiasP
Fri Jul 12, 2013 11:20 am
Forum: General Support
Topic: Memory allocation for C++ classes
Replies: 2
Views: 2865

Memory allocation for C++ classes

Hello,

I'm wondering if anyone has the same problem ... I'm using C++ for my application and want to instantiate some classes at startup.
What class I have to instantiate depend on a configuration.

In a non-embedded system I would definitely use new to create an instance. But what would you ...
by MathiasP
Tue Jun 04, 2013 8:59 am
Forum: General Support
Topic: [DONE] Problem with MS2ST macro
Replies: 5
Views: 4505

Re: [TODO] Problem with MS2ST macro

Hello Giovanni,

I did some tests for the CH_FREQUENCY values 100, 1000 and 10000.

The results look fine

Here my test code (tested with MS Visual Studio):

#define CH_FREQUENCY 10000

#define MS2ST(msec) ((((((msec)) * CH_FREQUENCY- 1L) / 1000L) +1L))
#define US2ST(usec) ((((((usec)) * CH ...
by MathiasP
Mon Jun 03, 2013 5:38 pm
Forum: General Support
Topic: [DONE] Problem with MS2ST macro
Replies: 5
Views: 4505

[DONE] Problem with MS2ST macro

Hello,

I think I found a bug in the MS2ST macro, when the value of CH_FREQUENCY is changed.

Here a example calculation for CH_FREQUENCY = 10000 and msec = 1:
(((((msec) - 1L) * CH_FREQUENCY) / 1000L) + 1L))
=> (((((1) - 1L) * 10000) / 1000L) + 1L))
=> (((0 * 10000) / 1000L) + 1L))
=> 1 tick
but ...