ARM Cortex-M Microcontroller startup files

Jens Bauer via Digitalmars-d digitalmars-d at puremagic.com
Fri May 1 02:26:16 PDT 2015


On Friday, 1 May 2015 at 07:30:03 UTC, Timo Sintonen wrote:
> On Thursday, 30 April 2015 at 23:49:52 UTC, Jens Bauer wrote:
>>
>> Most asserts on microcontrollers I've seen are just 
>> implemented as while(1){}
>> -But one could probably also trigger the debugger (BKPT), 
>> HardFault or RESET if necessary.
>> Perhaps the default could be while(1){} and then 
>> version(ASSERT_BKPT) could be used to add a breakpoint before 
>> that while(1){}. Thus --version=ASSERT_BKPT could be specified 
>> on the command-line.
>> Would it be possible to 'extend' an existing assert; eg. the 
>> user might want to be notified via the U(S)ART ?
>
> In a desktop computer it is easy to return to the system. A 
> flying aeroplane can not stop its engines and wait the pilot to 
> reboot...

The 'assert' is intended for debugging, right ?
If not enabling --version=ASSERT_LOOP, --version=ASSERT_BKPT, 
--version=ASSERT_RESET or any other version, then assert should 
simply default to an empty funciton.

Personally, I never ever used assert myself. I always handle the 
situation by making sure my data were in range; if they aren't, I 
correct them.

> We do have the 'weak' attribute now. Just make a weak default 
> handler that stops. Then the application designer can override 
> it with whatever the application needs.

Yes, of course. Why didn't I think of this ? :)


More information about the Digitalmars-d mailing list