This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

declaration link register R14

Hi everybody,

I actually work on a LPC2103, and I have a problem with a inline assembler.

In fact, I want to modify the Link Register R14, at the end of an interruption, in order to return in Main Programm at an other location.

But when I compile my programm, the compiler print this error:" error #20: identifier "R14" is undifined.

The problem is that I don't know how you can declare this kind of register.

thank in advance

Chris

  • I'm afraid that you cannot be helped here without referring you to the manual first.

    Recent feedback has determined that this is not acceptable. Sorry about that.

    http://www.keil.com/forum/docs/thread10151.asp

  • First, read the topic "ARMCC Virtual registers" in the RealView Compiler's User Guide. This will explain that is not possible to do what you are trying to with in-line assembly.

    You will have to do this in normal assembly code.

    I'm assuming that you know exactly what you are doing here, that you have no alternatives, that you are very familiar with the LPC2103, that you are proficient with ARM assembly programming and that you know the ARM AAPCS and ABI inside out.

    Otherwise you are best advised to try something else unless it is a trivial application.

    If you didn't think of any pitfalls of doing this in a C function then maybe you should look again for an alternative.

    That said, this is how a task scheduler in an ARM OS might work so it might be the right approach for your problem. You didn't provide any details on that.

  • "I'm assuming that you know exactly what you are doing here..."

    Hmmm... not sure that I'd assume that from the original question...

    ;-)

  • Not relevant to the question but "I actually work on a LPC2103" should better be worded as "I'm working on LPC2103 (at the moment)".

    No offence, we all have language difficulties (and I'm not a native English speaker either).

    The English 'actually' is not equal to French 'actuellement'. When I worked in France I was often puzzled with such a use of 'actually' by my French colleagues until another French guy, whose English was quite good, explained this common mistake to me.

    tum_

  • Thanks for your answers!!!

    My application seems to be simple. Indeed when an EINT2 interrupt occurs on the lpc2103, at any moment, I have to start again my Main from the beginning.

    For the moment, my interruption works correctly, but at the end of the interruption, I didn't manage to branch it at the beginning address of my Main.

    But it seems to be hard to do it in assembler, so, if you could advise me another solution in order to do it in standard C.

    Because I already try with these functions,SETJMP()and LONGJMP(), and my interruption wasn't re-armed.

    thank in advance.

  • "I have to start again my Main from the beginning"

    Why do you have to do that?
    Are you trying to perform some sort of software reset?

    It would probably be best if you explained what you're actually trying to achieve here - what is the requirement?

    Otherwise, we may just be discussing a fundamentally broken approach...

  • Ok sorry I resume from the beginning.

    My project consists of the development of an embedded software for a test device, which will be manage by the LPC2103.

    The aim of this software is to get back some informations through the serial link (UART1). The beginning of the communication is controlled by the EINT2 interruption which is controlled by button.
    Informations are read on the serial link, and then printed on the test device.

    However it's possible that the user don't need all informations and decide to push the button to have new informations.

    So it's necessary that my software can be able to go back to the beginning of the communication, in order to begin a new one.

    To make that, EINT2 interrupt have to be able to be branch to another address in my software.

    It isn't a software reset because the test device doesn't have to resume all from the beginning, but only the communication.

    As I already said, I want to know if it's possible doing that with inline assembler, embedded assembler or better if a funtion in C exists (I already try setjmp() and longjmp()).

    thank in advence

    Chris

  • To make that, EINT2 interrupt have to be able to be branch to another address in my software.

    That's not a strict necessity in your case. Manually messing with the return address should only be considered in very special cases (e.g. you are writing an operating system). This is because in such a case, many more things need to be taken care of than just changing the return address. An interrupt can occur at almost any point in your program - how is the interrupt service routine supposed to know how much stack/etc is being used at the moment ?

    In your case, it should be enough to have set/reset a flag in the interrupt service routine which is then evaluated by the regular program. Depending on the status of the flag, the program will either continue its output or start outputting a different set of data.

  • You seem to have made the wrong approach. You want to solve something simple by figuring out the most advanced solution possible.

    Whenever you request help with something on a forum, always write a LONG descriptive question, to make sure that the answer you get is a good answer - and not the answer you assumed that you wanted.

    We are talking about serial communication. That means that the main loop somewhere has a handler for serial data in and out.

    Let your interrupt set a flag.

    Let your serial handler look at the flag. If set, clear all pending input (if you are using a receive queue) and any pending output (if you are using a transmit queue) and set your state variables as expected.

    If your receive processing isn't a state machine, but a number of nested functions or for/while loops, let them break, return or whatever if the flag is set.

    When the main application code is prepared for handling new data, clear the reset flag and start process any new data from the serial port.

    Another thing: Unless the data have a specific format that you can not change, I would recommend to design the data format so that the user doesn't have to press a reset button. Let the data start with a "magic" character - then your application can watch the data stream and immediately resynchronize.

    That is the reason why most communication protocols normally are line-based if an end user is expected to input the data, or is using specific start-of-frame and end-of-frame characters if a machine is expected to send the data. How fun would it be if you had to press a "reset" button on your computer whenever you want the command-line prompt to know that you are ready to input data?

  • Thank a lot for all your answers!!!

    I saw that I had the wrong approach of my problem, and you allow me to see it.

    thanks and "bonjour de France"

    Chris

  • I saw that I had the wrong approach of my problem, and you allow me to see it.<p>

    Wow ... that was fast and easy. Good luck with your program !

    Usually, your question pops up in this forum at least once a month, and will usually result in the original poster becoming quite angry at everyone else and that they're so mean and don't tell him how to turn his simple program into a true nightmare to debug and maintain. (And on top of that, the original poster seems to be working with an 8051-type chip in most cases, which is even more unsuited for this type of hack than an ARM chip).