Use of "Off-chip XData Memory"?

Hi,

I'm running a small testapp to see if my 80c32 uP is running fine.
Therefore, I toggle P1_0 and next to this, I'm writing a value to a var defined in external RAM.

The RAM starts at address 0x0 and is 2kB long, so the end is at 0x7FF.
I define those ranges via 'Options - Options for Target 'Target 1' - Target' - Off-chip Xdata memory.

However, I see something very strange: when I declare my variable (for fun) at a fixed location outside the given range (e.g. unsigned char xdata testvar _at_ 0x850;), then I don't get a warning, even if I'm working outside the range.
Most strange of all, the variable is written and read correctly too (I'm toggling another pin if comparison is failing and I'm observing this pin with a scope, but I don't see any toggling => value exchange seems to be correct...)!

Can't understand this...

Anyone any idea?

--Geert

Parents
  • Hi,

    It may work because of how you have implemented your address decoding to select the extenral ram chip. If you have only implemented enough address decoding to address ram in 2k blocks rather than fully decoding the address so it is only seen in 0x0-0x7ff, then you will have the same memory block repeated 32 times ie. 0x0-0x7ff will also appear at 0x800-0xfff and so on all the way up to 0xf800-0xffff so when you try to read outside what you consider a valid range it is realy reading data from 'address & 0x7ff'. A good test would be write some data to 0x7ff then different data to 0xfff the do your comparison test and you will see that reading from 0x7ff and 0xfff will both have the same data.

    In terms of generating a warning indicating that you are outside your 2k address range - i dont think it is (personally) the compilers/linkers job to ensure that the address is valid. Imagine you had a memory mapped peripheral eg a duart at 0xf000-0xf00f, would you realy want to have to start putting in all these extra details for the peripherals as well as memory mamp details into the compiler - i know i wouldnt.

    Mark.

Reply
  • Hi,

    It may work because of how you have implemented your address decoding to select the extenral ram chip. If you have only implemented enough address decoding to address ram in 2k blocks rather than fully decoding the address so it is only seen in 0x0-0x7ff, then you will have the same memory block repeated 32 times ie. 0x0-0x7ff will also appear at 0x800-0xfff and so on all the way up to 0xf800-0xffff so when you try to read outside what you consider a valid range it is realy reading data from 'address & 0x7ff'. A good test would be write some data to 0x7ff then different data to 0xfff the do your comparison test and you will see that reading from 0x7ff and 0xfff will both have the same data.

    In terms of generating a warning indicating that you are outside your 2k address range - i dont think it is (personally) the compilers/linkers job to ensure that the address is valid. Imagine you had a memory mapped peripheral eg a duart at 0xf000-0xf00f, would you realy want to have to start putting in all these extra details for the peripherals as well as memory mamp details into the compiler - i know i wouldnt.

    Mark.

Children
More questions in this forum