Atmel AT89C51AC3 xdata initialization

Questions for programming 8051 microcontrollers in C or assembly using SDCC

Atmel AT89C51AC3 xdata initialization

Postby lordnoxx » Sun Jun 23, 2013 12:50 pm

Hi everybody.

I am currently working on an project where I want to store a sine wave lookup table
within the 2048 bytes of ERAM of the AT89C51AC3. Thus before my code enters the main()
it initializes this array like that:

Code: Select all
__xdata unsigned char dac_values[128]={128,134,140,146,152,158,165,170,176,182,188,193,198,203,208,213,218,222,226,230,234,
237,240,243,245,248,250,251,253,254,254,255,255,255,254,254,253,251,250,248,245,243,
240,237,234,230,226,222,218,213,208,203,198,193,188,182,176,170,165,158,152,146,140,
134,128,121,115,109,103,97,90,85,79,73,67,62,57,52,47,42,37,33,29,25,21,18,15,12,10,
7,5,4,2,1,1,0,0,0,1,1,2,4,5,7,10,12,15,18,21,25,29,33,37,42,47,52,57,62,67,73,79,85,
90,97,103,109,115,121};

Curiously the data in that array gets corrupted. For testing purposes I let the µC send the contents of the array via UART
to my computer. What I get looks like this:

128 134 140 146 152 158 165 170 176 182 188 193 198 203 208 213 218 222 226 230 234 237 240 243 245 248 250 251 253 254 254
255 255 255 254 254 253 251 250 248 245 243 240 237 234 230 226 222 218 213 208 203 198 193 188 182 176 170 165 158 152 146
140 134 128 121 115 109 103 97 90 85 79 73 67 62 57 52 47 42 37 33 29 25 21 18 15 12 10 7 5 0 0 4 96 8 0 16 16 8 0 16 0 1 2
0 2 0 0 0 0 0 0 66 0 0 17 0 0 0 32 0 80 4 2 132 20 0

As you can see the last few elements starting at 12, 10, 7, 5, ..... are corrupted.

Now...I read something in the sdcc manual about startup code and MPAGE SFR at 0x92 or in case of an µC with dual data pointers
(as the AT89C51AC3) reassembling the crtxinit.asm with DUAL_DPTR = 1.

Do you guys think my problem cam be solved by one of the last mentioned things?
If so...I would be very thankful if you could give me some advice in solving my problem. Like how to reassemble crtxinit.asm.
Sure...giving it to an assembler....but where to put the resulting output file?

Hope you can help me on this problems.

Markus
lordnoxx
 
Posts: 1
Joined: Sun Jun 23, 2013 12:48 pm

Re: Atmel AT89C51AC3 xdata initialization

Postby brennen » Mon Jun 24, 2013 1:41 pm

Basically, you would copy crtxinit.asm into your project folder, and change the proper #define. Then you would assemble the file. After that, you would add the resulting .rel file to the files that you linked in with your final executable.
brennen
Site Admin
 
Posts: 395
Joined: Sun Aug 17, 2008 2:15 pm


Return to 8051 Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron