![]() |
|
|
Thread Tools |
|
#11
|
|||
|
|||
|
I think we are at crossed purposes here, I am not writing an exception handler, this is a system that records errors raised by functions, for example
Code:
someFunc(int pinNumber) {
if (pinNumber >= MAX_PINS)
SYS_ERROR (ERR_BAD_PIN_NUMBER | pinNumber);
...
}
In the above example SYS_ERROR is a macro that records the address of the code then calls a raiseError() function that handles it. As far as I can tell this is working and I've been using it for a few days now. That said, now that I have another look at my get_PC() function I can't for the life of me see how it does work, and yet it appears to. It's too late to investigate now, that's a tomorrow job.
__________________
Rob Gray, aka the GRAYnomad, www.robgray.com |
|
#12
|
|||
|
|||
|
Quote:
Besides, what is the use of the PC in HLL? You need to pinpoint the bug in the source, not in the hex. Quote:
|
|
#13
|
|||
|
|||
|
Quote:
If I have the address I can look at the map file to find the culprit. I haven't used assert for years, maybe it can be made to do this I'm not sure but certainly a nice human-readable error message is no good to this application. Quote:
Can you elaborate?
__________________
Rob Gray, aka the GRAYnomad, www.robgray.com |
|
#14
|
|||||
|
|||||
|
Quote:
It is you who provide the implementation of the core of the assert(). I sometimes insert asm("bkpt 0x00"), sometimes asm("nop") and nothing stops you from providing a more/less advanced BSOD. I wonder why cannot you use OCD for asserts? Why necessarily a blinking LED, a.k.a. logic analyser, when (most of) ARMs have full-blown features on-board? But, if you really need that IO, unless it is tn4-ish "single-chip embedded system", I suggest a software driven UART tx on an arbitrary pin. Quote:
Quote:
Quote:
Quote:
It belongs to System Control Block (SCB).A Debug Return Address should give you a PC value. As an alternative, you can also try reading DWT_PCSR. Last edited by Brutte; 08-05-2012 at 05:50 PM. |
|
#15
|
|||
|
|||
|
I've had a good look at assert and remember now why I haven't used it in the past, the standard version chews too much program memory. Each assert eats about 40-60 bytes depending on the file name and the assertion text.
That said I like the idea of being more in line with the standard technique and with these chips maybe a few k used for that is a good trade off, so as you say I'm modifying the assert code to be a little less verbose and just print the file/line and maybe an error code. Quote:
and am having a hard time getting used to all the great debugging tools now available.While developing of course I have the semihost serial connection, in the field these devices will be connected to a control network and I think it makes sense to have the production version of the assert code packetise the same string and send it to the network. I grep'd "DCRSR" in both my project folder and the Xpresso install folder. The string only appears in two core_cm3.h files, I assume then that this is only available with an M3 and that's why I could find no mention of it in the LPC1227 UM.
__________________
Rob Gray, aka the GRAYnomad, www.robgray.com |
|
#16
|
||||||
|
||||||
|
Quote:
Quote:
It just terminates the execution because the flow or timing didn't meet the expectation. All passengers are already dead so you do not need to be worried about other resources - the whole chip is yours. Code:
__attribute__((noinline))
__attribute__((noreturn))
void assert_abort(char* file,char* fun, uint16_t line,...){
overtake_arbitrary_resources_and_shift_out_some_chars_out(SDIO); //or ethernet, or semihosting or blinking led if you like.
puts("Oops, assertion failed in ");
puts(file);
..
..
//if you really need that PC, push out lr
..
puts(" and you are kindly requested to fix that.\n");
shutdown();
}
#define assert(condition) if(condition){void(0)}else {assert_abort(__FILE__,__FUNC__,__LINE__)}//these are const strings in gcc, I hope.
Quote:
Quote:
Quote:
Perhaps you should start with simpler PCSR: Code:
my_program_counter=DWT->PCSR; Quote:
You should remove it in RELEASE because those consume CPU and rom. Perhaps you need something different than assert. Like log or something similar.. |
|
#17
|
|||||
|
|||||
|
Quote:
In this case the error should probably be published to the network (on the assumption that there is a node somewhere that will record the event) then ignored. If the error is internal then that's a different story, you probably have to assume that the ability to publish to a network is compromised, in this case I think the blinking LED/software serial option is the only thing to do. How that is read is another story, maybe a tech has to plug in a terminal. Quote:
Quote:
There is still the issue of reading a fatal error code in the field, as I said maybe a terminal but an LA is also an option. Unfortunately no user is likely to have either so we're maybe back to the flashing LED. Quote:
Quote:
__________________
Rob Gray, aka the GRAYnomad, www.robgray.com |
|
#18
|
||||
|
||||
|
Quote:
but you can make your own "sometimes non-fatal" version.Quote:
Anyway, toggling pins can be quite entertaining. Quote:
Quote:
|
|
#19
|
|||
|
|||
|
Quote:
Quote:
![]() Thanks for the link, I'll need to delve deeper into the guts of the processor at some point and that looks pretty interesting.
__________________
Rob Gray, aka the GRAYnomad, www.robgray.com |
![]() |
| Thread Tools | |
|
|