We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello again,
I'm working with the AT91RM9200 controller. How is it possible to get a printf() message over the usart1 if a dara abort or undefined instruction has occured?
I've one .c file with all ISR; for example:
void AT91F_DataAbort() { printf("Data Abort detected\n"); while (1); }
and the void AT91F_LowLevelInit() function.
But which changes I have to made in the startup code file to run this function is a data abort occured?
IS it something like that (I've found in the www)
IMPORT AT91F_LowLevelInit ldr r1, = AT91_SVC_Stack_Begin bic r1, r1, #3 ; Insure word alignement mov sp, r1 ; Init stack SYS ldr r0, = AT91F_LowLevelInit mov lr, pc bx r0 ; Setup Stack for each mode LDR R0, =Stack_Top
Maybe someone of you could give me a example, where I could see the changes in the startup code.
best regards Johannes
How is it possible to get a printf() message over the usart1 if a dara abort or undefined instruction has occured?
printf() is just about the last function you should even think of calling from an ISR. Roughly said, anything beyond a simple putc() or two would be madness.
Catastrophic exceptions like those have to be avoided, not decorated.
you're right, but what happened if a data abort occured??? - nothing... so the ISR is the last thing and so I only want to get a message over the usart that such a data abort occured... that's all. Atmel do the same in the code examples (but they use a different startup code - so I don't know what I had to change to get the same result...
Johannes
you're right, but what happened if a data abort occured???
The debugger you have connected to the JTAG debug port of your ARM MCU kicks in and you get to do some detective work. No amount of printf()ing can possibly be more helpful than that.
IMPORT AT91F_DataAbort Vectors LDR PC,Reset_Addr LDR PC,Undef_Addr LDR PC,SWI_Addr LDR PC,PAbt_Addr LDR PC,DAbt_Addr DCD 0 LCR PC,IRQ_Addr . . DAbt_Addr DCD AT91F_DataAbort . .
This will call YOUR C function AT91F_DataAbort when a data abort happens.
The "best" solution "may" be to have some variables that survives a reboot. Let the data abort exception record the most important register information (where and why). Then perform a reset and restart the application.
If you do have any data that survives a reset, your main() app can then check if it was a normal reset, or the result of a data abort. In case of a data abort, you may log info to a serial port, write down a note to flash file system, ... before resuming the normal operation.
If your app isn't controlling a nuclear facility, and you get on average one data abort/year, you might possibly ignore it. If you get too many in relation to your reliability requirements, you may retrieve information from your unit(s) and hunt down what is wrong.
One of the problems you have, is that you don't know how stable your processor is when it reaches the data abort exception. A sprintf() buffer overflow may have made all *printf() completely unreliable.