Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

89c2051...a lookuptable in sdccC or keilC

Status
Not open for further replies.

vinayby

Newbie level 4
Joined
Jul 5, 2004
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
70
.. 89c2051 has 2k code mem (onchip rom)

i want ,say a sin() lookuptable of 0xff height..

1)code unsigned char sintable[0x100]; //doesnt work says' u cant modify lvalue
2)tried xdata in place of it compiles fine.. but it is meaningless though..
(or leave aside sin() ,something arr=0xf1; in a loop shud show me something in the hex file.. nothing showsup)
3)why can't i write to code.... if i can do that in asm. with "db BYTE";

any #pragma directive can help?

even sdcc didnt help.. can some1 help me clear these things...

i used:
in Keil->targetOptions->use 0-0x07ff selected + small model, etc etc
sdcc -> default(small model)
 

try code const unsigned char sintable[0x100]; //doesnt work says' u cant modify lvalue

Problem is that you can not write to code so you have to initialize your array at compile time and can not modify it later ...

best regards
 

IMHO, "code const unsigned char sintable[0x100]" does not help you at all (but it is more appropriate C style for segment CODE) if you have "wrong intention of using the sintable[]". The problem is not in this line as long as you would try to do for example "something = sintable[0x01];" only. Your problem is, that in your code is line like "sintable[0x01] = something;".
You CAN NOT modify the 2k code mem (onchip rom) by a software itself. This is the basic rule for '51 architecture (it is not Intel x86 or so called Neumann architecture in general. (Sorry, if I am wrong with its name, but I am not an expert in the CPU theory.)
So, if you would like to create the lookup table, you need to forget to modify any sintable[] member, and you can only to read out its values. Whole sintable[] have to be initialized in the code as:
code const char sintable [0x100] = {
/* 256 values for initialisation of an array: 0x00, ... */
} // sintable[]

P.S.:
Of course, somebody could point out some '51 chips (Cygnals for example) which allows you to modify "code segment" by the software itself, but I would treat them as an exception to the general rule about character of code segment, because to be able to modify code inside these microprocessors requires some extra programming and it is "advanced technique".
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top