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

Absolute address for FUNCTIONS in CODE-space

Does anyone knows a methode, to declare a function in a specific CODE address in C51?
Something lika a org xxxx in assembler !

Parents
  • Let me try to explain you what I'm trying to do:

    I'm working with uPSD3212 from ST electronics. In this processor I have two flashes and I can configure PSEN to active Flash one or Flash two and the some for RD signal, in other word I can use one flash as a code and the other as a Data and vice-versa.

    Take a look what I'm doing:

    1. I record a simple program in the flash one and a simple program in the flash two.
    2. When I reset my device the second Flash is configured as code (PSEN access it) and the second as a Data (RD access it).
    3. In my code, on second flash, I change PSEN to access my fist flash and RD to access my second flash. In other words I change my code from the second flash to the first (I'm trying to make a bootloader).

    When I make it, my "program count" stay with the same value, and, of course, my program in the first flash doesn't work fine.

    There is a way to jump to same particular adress (ljmp XXXX) and put a function in this adress (org XXX) using C?

Reply
  • Let me try to explain you what I'm trying to do:

    I'm working with uPSD3212 from ST electronics. In this processor I have two flashes and I can configure PSEN to active Flash one or Flash two and the some for RD signal, in other word I can use one flash as a code and the other as a Data and vice-versa.

    Take a look what I'm doing:

    1. I record a simple program in the flash one and a simple program in the flash two.
    2. When I reset my device the second Flash is configured as code (PSEN access it) and the second as a Data (RD access it).
    3. In my code, on second flash, I change PSEN to access my fist flash and RD to access my second flash. In other words I change my code from the second flash to the first (I'm trying to make a bootloader).

    When I make it, my "program count" stay with the same value, and, of course, my program in the first flash doesn't work fine.

    There is a way to jump to same particular adress (ljmp XXXX) and put a function in this adress (org XXX) using C?

Children
  • What you're doing with your two functions is a combination of traditional C51 techniques "code banking" and "xdata banking". Neither would strictly need any knowledge about absolute memory locations for functions if you had let the C compiler help you doing it.

    If you insist doing it on your own, you'll have to investigate the suggestions you already got: put functions in separate segments, let the linker place those segments at fixed locations.