Flexbus Bus cycle Question

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Flexbus Bus cycle Question

Jump to solution
1,227 Views
jimmorris
Contributor I

I have some issues that are leading me to believe that the Flexbus Appnote for the Kinetis processors and the descriptions in the data sheets are not telling me the entire store.

To make a long story short, I have a design where I need to interface My MK10FN1M0VLQ12 K10 micro controller with a memory mapped device in 16-bit mode, with the device having 16 directly accessible 16-bit registers.  I have that working using the multiplexed AD signals, such that FB_AD[3:0] are tied to ADDR[3:0] on my device, FB_AD[32:16] are tied to DATA[15:0] of my device, and the FB_OE#, FB_CS0# and FB_RW are used to properly generate the signals the device expects for read and write operations.  The device has an ACK# signal which drives back to FB_TA# on my K10 micro controller.

I am then memory mapping the device in C as uint16_t pointers, like this:

// Setup base address of device

const uint32_t mydevice_base_addr = 0x60000000;

// Setup register pointers

mydevice_register_A = (uint16_t *) (mydevice_base_addr + 0x0);

mydevice_register_B = (uint16_t *) (mydevice_base_addr + 0x1);

mydevice_register_C = (uint16_t *) (mydevice_base_addr + 0x2);

mydevice_register_D = (uint16_t *) (mydevice_base_addr + 0x3);

And so on.....

I am using Processor Expert, and have the CS0# of the Processor component set to be 16-bit for the port width, and so on.

What I am seeing  happen as I go on through trying to initialize my device, using a logic analyzer to watch the bus, is that while things SEEM to work on the surface, is that any access to an EVEN register on the device works as expected. I will see a single 16-bit read or write bus cycle.  However, ANY access at all to an ODD register appears to result in the expected access, followed by an access to the next register up. For example, single step the code in KDS with a write the register at 0x0 will result in a SINGLE write to the bus.  I get one chip select cycle on the Flexbus on the logic analyzer.  However, if I attempt to write (or read) a ODD address such as offset 0x1, I get TWO bus cycles generated by the K10.  I'll get the expected cycle to 0x1, followed by a cycle to 0x2.

Unfortunately, the end result is that I cannot configure and use my memory mapped device properly. It has specific sequences that require for example that I write registers 0xD 0xE and 0xF with specific values in a specific sequence.  When I do those 3 writes, I get a write to 0xD followed by a write to 0xE, a write to 0xE (the next line of code), then a write to 0xF followed by a write to 0x0.  I've gone so far as to do inline __asm() to test this, using the STRH operation, which should move a half word, and still get this behavior.

So the question is, does the Kinetis and/or KDS prevent single 16-bit port accesses on the Flexbus, even when the Flexbus is set to LEFT ALIGNED 16-bit bus width?  Why does it work for even and not for odd addresses?

How can I resolve this? I know a PCB change may be required, but the question is, can I avoid requiring external address latches and right aligning the data?  Right now I feel like going to full 32-bit bus, with AD[3:0] for the address (latched) and AD[15:0] for the data, with the port width set to 32-bits, but with the bits AD[31:16] not tied to anything, MIGHT fix this, but am not going to spend the money on that level of change until I understand fully the issue and the resolution.

Thanks!

Jim Morris

Huntsville, Alabama

Tags (2)
0 Kudos
1 Solution
910 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi Jim,

Technically hardware is able to perform 8-bit and 32-bit accesses. For 16-bit access you will see that the Chip Select signal behaves the same as a 32-bit access, however the compiler is able to perform the necessary instructions to return 16-bit data.

Please see attachment in this post:

FlexBus in 16 bit mode and 8 bit access

Probably you may need 8-bit access to avoid double reads to your device.


Best regards,
Carlos

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
3 Replies
911 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi Jim,

Technically hardware is able to perform 8-bit and 32-bit accesses. For 16-bit access you will see that the Chip Select signal behaves the same as a 32-bit access, however the compiler is able to perform the necessary instructions to return 16-bit data.

Please see attachment in this post:

FlexBus in 16 bit mode and 8 bit access

Probably you may need 8-bit access to avoid double reads to your device.


Best regards,
Carlos

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
909 Views
jimmorris
Contributor I

As a followup to anyone reading this thread, my findings were that any access to an address with a 16 bit bus on an odd address causes a double 16-bit cycle to occur.  What I ultimately had to do to solve the issue was to disable the FB_ADDR lines, and drive the address lines using a Processor Expert GPIO component.  So my code has to set the address specifically, via the GPIO, for external memory mapped devices.  The reads in the Kinetis memory space always happen to the base address of the device, so that we only get a single CS/RE/WE for each 16-bit read or write.  Not much overhead - just means I cannot increment a pointer to do memory mapped access - I just set the address on one line of C code, and read/write the pointer to the base address of the device in the second line.

0 Kudos
910 Views
jimmorris
Contributor I

I am attaching a screenshot showing the issue. Note that the data lines are not connected on my logic analyzer right now, and are not pertinent.  The code in question looks like this:

Here’s the code:

  // Perform a HARD RESET (same as using the reset pin of the ADV212)

  *adv212_register_BOOT = 0x0040;

  // SET INTERNAL CLOCKS (PLL_HI AND PLL_LO REGISTERS)

  *adv212_register_PLL_HI = 0x0008;

  *adv212_register_PLL_LO = 0x0004;

As you can see, 3 writes to registers 0xD, 0xE and 0xF - all 16-bit registers.  And I've even done it with inline ASM code.  However the bus generates FIVE bus cycles.  The legitimate cycles are the 1st, the 3rd and the 4th. The 2nd and 5th are the ones screwing us up, and are not even in the code.  I can single step and get the same behavior. Write any EVEN address, get a single write (or read). Access any ODD address, get a bus cycle to the specific address plus the next address.

In case you wonder, the FB_CS0# is the device CS.  The device RD plus is the FB_OE#. The device WE pulse is an OR of FB_CS0# and FB_RW.

Help is appreciated.

Jim Morris

Huntsville, Alabama

0 Kudos