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

c-variable definitions in assembly main

Hi,

I am programming on the Cypress FX2 (8051 compatible) and I have a problem that my variables declared in a c-function do not get initializes properly.

My main program is written in assembly, since I need to have an ISR, which is very short and i want to have full control over what the proc. does during that ISR. I have to include a c-file in my project, which initializes a bunch of registers for a special interface on my USB chip. The problem is that the linker does not include that data segment.

my data is defined this way:

const char xdata WaveData[128] = {128 bytes}

do i need to write an initialization function in C, which moves all that data or is there a way for force the inclusion of that data segment?

thanks,

Greg

ps.: sorry if i am not clear.

Parents
  • What would the need for a very tightly optimized ISR have to do with writing the main function in assembler?

    Your core problem almost certainly is that because your main function is not written in C, the C runtime startup code isn't being linked in and run. See the manual to learn about startup.a51 and the all the machinery it contains.

    As to your initialized block: given it's "const" already, what would be the point having it in xdata? The right choice of memory space would be "code" here, I think. For one thing, it would no longer need the startup.a51 routines to copy data to xram for you, that way.

Reply
  • What would the need for a very tightly optimized ISR have to do with writing the main function in assembler?

    Your core problem almost certainly is that because your main function is not written in C, the C runtime startup code isn't being linked in and run. See the manual to learn about startup.a51 and the all the machinery it contains.

    As to your initialized block: given it's "const" already, what would be the point having it in xdata? The right choice of memory space would be "code" here, I think. For one thing, it would no longer need the startup.a51 routines to copy data to xram for you, that way.

Children