Accessing the external bus

Discussion to talk about software related topics only.
Post Reply
v8dave
Posts: 333
Joined: Thu Dec 31, 2009 8:31 pm

Accessing the external bus

Post by v8dave »

Hi All,

I have copied some code from the MOD5234 demo and tried to modify it for my memory configuration but I am not seeing the correct information on the logic analyser.

This is the code I used.

#define BASEADDRESS ( 0xA0000000 )

static volatile WORD *pDisplayCommand = ( WORD* ) (BASEADDRESS);
static volatile WORD *pDisplayData = ( WORD* ) (BASEADDRESS + 1);

My external device is on a 16 bit data bus. Here is the configuration I have used to setup the Chip select. I know this is working as I can see it on the logic analyser when I access that address but the databus is not correct. I have a feeling it is the above definition that is causing the issue. I can't find anything in the documentation on how to setup and use external memory other than the demo app I found.

sim.cs[2].csar = ( BASEADDRESS >> 16 );
sim.cs[2].cscr = 0x2180; // 0010 0001 1000 0000
sim.cs[2].csmr = 0x001F0001;

Cheers,
Dave...
thomastaranowski
Posts: 82
Joined: Sun May 11, 2008 2:17 pm
Location: Los Angeles, CA
Contact:

Re: Accessing the external bus

Post by thomastaranowski »

I have a similar setup with an external 16-bit latch register I can read/write from.
The only weird thing I recall running into was that the 5282 puts 16-bit values out on address lines [16:32], bit 0 corresponds to address line 16, so if watching with a logic analyzer, it might look weird.


My chip select setup is identical to yours.

Here's a stripped down example of how I use it to write to an outlatch register sitting out at 0xd0000010.

volatile unsigned short * const outlatch = (unsigned short * const)0xd0000010;

To set it, I basically do this:
unsigned short foo=0x0001;
*outlatch = foo;

The only weird thing I see in your setup is:
static volatile WORD *pDisplayData = ( WORD* ) (BASEADDRESS + 1);

This puts the displayData at 0xa0000001, which isn't word aligned. Looks like you might want
static volatile WORD *pDisplayData = ( WORD* ) (BASEADDRESS + 2);
OR
static volatile WORD *pDisplayData = pDisplayCommand + 1;
v8dave
Posts: 333
Joined: Thu Dec 31, 2009 8:31 pm

Re: Accessing the external bus

Post by v8dave »

Thanks Thomas,

My databus is indeed connected to DB16-31 as this is what is brought out to the IO pins. I used to work with the MC68332 many years ago so learned to know about the use of the bus. At that time it was all in assembly!! :)

I thought about using the word alignment. This is the confusing part. I currently have A1 connected to the IO device to act as the Command/Data selection (is an LCD interface) as I recall that A0 is not used due to the word alignment. I had forgotten about the pointer maths so thanks for pointing that out.

I'll test it later today.

Cheers,
Dave...
v8dave
Posts: 333
Joined: Thu Dec 31, 2009 8:31 pm

Re: Accessing the external bus

Post by v8dave »

Got it.

If the address is not word aligned, the CPU outputs it as two 8 bit bytes instead.!!

Now just need the see if the LCD will respond now that the data is appearing on the bus.

Dave...
v8dave
Posts: 333
Joined: Thu Dec 31, 2009 8:31 pm

Re: Accessing the external bus

Post by v8dave »

Just a quick update. I got it working tonight. I had to delay the A1 address and CS chip select to the LCD. There is an E enable input to the LCD that is a direct inverted version of the CS but I needed the small delay on A1 and CS so the E would fall before they changed state. A 74HC04 did the trick nicely as there was 5 spare gates on it anyway as this was used to generate E from CS in the design.

The LCD is now working in 16 bit mode on the MOD5234.

Cheers for all your comments.!

Dave...
Post Reply