problems using division ROM

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

problems using division ROM

2,952件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mrob on Mon Oct 29 10:14:04 MST 2012
Hello,

I'm having some issues getting my project to use the division ROM properly.

Overloading the "/" operator works fine, but the "%" operator will not compile.
I have the function defined as
__value_in_regs uidiv_return __aeabi_uidivmod(unsigned numerator, unsigned denominator)


The compiler doesn't seem to recognize the "__value_in_regs" flag.
If I remove the flag it compiles, but the resulting modulus function doesn't work.  If I call the ROM modulus function directly, everythign is fine.

How do I get LPCxpresso to recognize the "__value_in_regs" flag properly?

I am using Version: LPCXpresso v4.2.3 [Build 292] [30/05/2012]
0 件の賞賛
返信
16 返答(返信)

2,883件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fjrg76 on Wed Nov 07 22:43:41 MST 2012

Quote: mrob
Well, I tried copying the "aeabi_romdiv_patch.s"file over from a LPC12xx project and adding the project settings to my 11u24 project.  Unfortunately it did not work.  The asm listing still shows it calling the standard division routines, not the ROM routines.  It seems that it had no effect on the project at all.



Look into your cr_startup_lpc11xx.c file and you'll find the references to the ROM routines. E.g.

[FONT=Courier New]Line 341 cr_startup_lpc12xx.c

// Patch the AEABI integer divide functions to use MCU's romdivide library
#ifdef __USE_ROMDIVIDE
       // Get base address of romdivide area in MCU ROM
       unsigned int *pDivRom = (unsigned int *) DIVROM_BASE;
       // Load first word of romdivide area, which contains address of first
       // divide function.
       unsigned int *romdiv_func = (unsigned int *)*pDivRom;
       // Get address of first divide function (signed divide)
       pDivRom_idiv = (unsigned int *)*romdiv_func;
       // Get address of second divide function (unsigned divide)
       pDivRom_uidiv= (unsigned int *)*(romdiv_func+1);
#endif[/FONT]
0 件の賞賛
返信

2,883件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fjrg76 on Wed Nov 07 22:37:31 MST 2012
Hi

Go to Project->Properties->C/C++ Build->Settings, and in the "Defined symbols  (-D)" pane add this symbol

__USE_ROMDIVIDE


Hope it helps.
0 件の賞賛
返信

2,883件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Skashkash on Wed Nov 07 09:38:49 MST 2012

Quote: mrob
I placed the put a file "R2.c" with your code into my project, and i got the following error when I tried to build the project

../src/R2.c:59:17: error: initializer element is not constant




Fwiw, I get that same error with the code from lpcware. (lpcxpresso 4.3.0)
  Not quite sure how to clear it.
0 件の賞賛
返信

2,883件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Mon Nov 05 00:53:08 MST 2012
The compiler is *identical* between 4.2.3 and 4.3.0. In fact, it is identical in all versions 4.x.x.
0 件の賞賛
返信

2,883件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by daniel.widyanto on Sun Nov 04 20:21:28 MST 2012
I used LPCXpresso 4.2.3, and compiled this without any issue.

I'm quite surprise that newer compiler assumes pDivROM assignment as not constant assignment, since I never declared pDivROM as const anyway.

I've removed the 'const' from ROM struct. It should have less stringent compiler check and pass through the compilation without any issue.
0 件の賞賛
返信

2,883件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mrob on Fri Nov 02 08:54:59 MST 2012
I placed the put a file "R2.c" with your code into my project, and i got the following error when I tried to build the project

../src/R2.c:59:17: error: initializer element is not constant
0 件の賞賛
返信

2,883件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by daniel.widyanto on Fri Nov 02 02:33:33 MST 2012
Please refer to http://www.lpcware.com/content/blog/using-integer-division-routines-rom-lpc11uxx
0 件の賞賛
返信

2,883件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mrob on Tue Oct 30 21:30:41 MST 2012
Well, I tried copying the "aeabi_romdiv_patch.s"file over from a LPC12xx project and adding the project settings to my 11u24 project.  Unfortunately it did not work.  The asm listing still shows it calling the standard division routines, not the ROM routines.  It seems that it had no effect on the project at all.

Until someone else has a solution to get the DIVROM to overload the modulus operator on an 11u24, I'm just going to stick with calling the ROM manually.
0 件の賞賛
返信

2,883件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by graynomad on Tue Oct 30 18:51:46 MST 2012
Doh, thanks I see it now.
0 件の賞賛
返信

2,883件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Tue Oct 30 18:28:11 MST 2012
That is becuase you have a library project. Library projects are not linked and so have no linker... You only have a linker when you are creating an application.
0 件の賞賛
返信

2,883件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by graynomad on Tue Oct 30 18:15:28 MST 2012
Project > properties

All I can see is

MCU C Compiler
MCU Assembler
MCU Archiver
0 件の賞賛
返信

2,883件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Tue Oct 30 17:52:10 MST 2012
There *is* a Miscellaneous section for the MCU Linker. Where are you looking?
0 件の賞賛
返信

2,883件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by graynomad on Tue Oct 30 17:18:26 MST 2012
In the CR page about this it says the following


Quote:

[LIST=1]
[*]Select the project in the Project Explorer view and then open the Project properties.
[*]In the left-hand list of the Properties window, open "C/C++ Build" and select "Settings" and then the "Tool Settings" tab.
[*]Now choose "MCU C Compiler - Symbols" and add __USE_ROMDIVIDE to the "Defined Symbols".
[*]Now choose "MCU Assembler - General" and add   -D__USE_ROMDIVIDE  to the "Assembler flags".
[*]Now choose "MCU Linker - Miscellaneous" and add --allow-multiple-definition to the "Other Options".
[*]Repeat steps 3,4 and 5 for all Build Configurations (typically Debug and Release).
[/LIST]



Step 5, there is no "MCU Linker - Miscellaneous" section :confused:

There is a "MCU C Compiler - Miscellaneous" section with a "Other flags" text box that looks about right.

Is that where is --allow-multiple-definition supposed to go?
0 件の賞賛
返信

2,883件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mrob on Tue Oct 30 11:15:59 MST 2012
I'm using an LPC11u24 /401

I did look at the link for the 12xx, but it didn't seem to do anything for my 11u24 project (probably because of the missing "aeabi_romdiv_patch.s" file).  I guess I'll start up a 12xx project and see if I can use the patch file in my 11u24 project.
0 件の賞賛
返信

2,883件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Mon Oct 29 22:23:25 MST 2012
__value_in_regs is a Keil-only compiler extension.

Did you see this?
http://support.code-red-tech.com/CodeRedWiki/RomDivide
0 件の賞賛
返信

2,883件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Mon Oct 29 22:21:26 MST 2012
__value_in_regs is an ARM Realview/Keil specific compiler extension and is not available in the GNU compiler used by LPCXpresso.

What MCU are you using? If you are using LPC12, then the project wizard contains functionality to automatically map in the ROM divide routines...

http://support.code-red-tech.com/CodeRedWiki/RomDivide

Regards,
CodeRedSupport
0 件の賞賛
返信