<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: K60 flexbus problems in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-flexbus-problems/m-p/363387#M18583</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andrew,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are using Flexbus in multiplexed mode.&lt;/P&gt;&lt;P&gt;For the Flexbus 16bits data lines at FB_AD[15:0] pins, it need to set CSCRn[BLS] = 1, more detailed info, please check below picture:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="flexbus.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/40457i25CD26CABCF7BC5E/image-size/large?v=v2&amp;amp;px=999" role="button" title="flexbus.png" alt="flexbus.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And it need to check the hardware connection, for it using 16-bit data port, the CPLD address A0 pin should connect with Flexbus_AD[1] pin.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Wish it helps.&lt;BR /&gt;best regards &lt;BR /&gt;Ma Hui&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Oct 2014 06:02:13 GMT</pubDate>
    <dc:creator>Hui_Ma</dc:creator>
    <dc:date>2014-10-30T06:02:13Z</dc:date>
    <item>
      <title>K60 flexbus problems</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-flexbus-problems/m-p/363386#M18582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to access a 16 bit fully multiplexed 64k CPLD which is hooked up to the external bus interface on chip select 0. I am using the TWR-K60F120M and MQX 4.1. The following code runs in a standard task.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14146081395817773" jivemacro_uid="_14146081395817773" modifiedtitle="true"&gt;
&lt;P&gt;#define A2D_CPLD_START_ADDRESS (*(volatile unsigned char*)(0xA0000000))&lt;/P&gt;
&lt;P&gt;void flexbus_init(void) {&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; SIM_SCGC7 |= SIM_SCGC7_FLEXBUS_MASK; // Enable the clock to the FlexBus&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; SIM_CLKDIV1 |= SIM_CLKDIV1_OUTDIV3(0); // no divisor&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; // Set the GPIO ports clocks&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; SIM_SCGC5 = SIM_SCGC5_PORTB_MASK | SIM_SCGC5_PORTC_MASK | SIM_SCGC5_PORTD_MASK;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; // 16 bit multiplexing - so set 16 bit address, latch, then those 16 bits become data lines&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PORTB_PCR18 = PORT_PCR_MUX(5); // fb_ad[15]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PORTC_PCR0 = PORT_PCR_MUX(5); // fb_ad[14]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PORTC_PCR1 = PORT_PCR_MUX(5); // fb_ad[13]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PORTC_PCR2 = PORT_PCR_MUX(5); // fb_ad[12]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PORTC_PCR4 = PORT_PCR_MUX(5); // fb_ad[11]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PORTC_PCR5 = PORT_PCR_MUX(5); // fb_ad[10]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PORTC_PCR6 = PORT_PCR_MUX(5); // fb_ad[9]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PORTC_PCR7 = PORT_PCR_MUX(5); // fb_ad[8]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PORTC_PCR8 = PORT_PCR_MUX(5); // fb_ad[7]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PORTC_PCR9 = PORT_PCR_MUX(5); // fb_ad[6]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PORTC_PCR10 = PORT_PCR_MUX(5); // fb_ad[5]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PORTD_PCR2 = PORT_PCR_MUX(5); // fb_ad[4]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PORTD_PCR3 = PORT_PCR_MUX(5); // fb_ad[3]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PORTD_PCR4 = PORT_PCR_MUX(5); // fb_ad[2]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PORTD_PCR5 = PORT_PCR_MUX(5); // fb_ad[1]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PORTD_PCR6 = PORT_PCR_MUX(5); // fb_ad[0]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; // Other lines - Output Enable, Read/Write, ChipSelect0, Address Latch Enable&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PORTB_PCR19 = PORT_PCR_MUX(5); // fb_oe_b [nEBI_OE]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PORTC_PCR11 = PORT_PCR_MUX(5); // fb_rw_b [EBI_R/W]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PORTD_PCR1 = PORT_PCR_MUX(5); // fb_cs0_b [nEBI_CSO]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PORTD_PCR0 = PORT_PCR_MUX(5); // fb_ale&amp;nbsp;&amp;nbsp; [EBI_ALE/nEBI_CSI]&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; // Setup the chip select 1 control register (see K60P144M150SF3RM.pdf, section 33.3.3)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; FB_CSCR0 = FB_CSCR_PS(0x2) // 16-bit port&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //| FB_CSCR_BLS_MASK // data is right shifted, i.e. appears on bits 0-15&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | FB_CSCR_EXTS_MASK&lt;/P&gt;
&lt;P&gt;&amp;nbsp; | FB_CSCR_AA_MASK // auto-acknowledge...&lt;/P&gt;
&lt;P&gt;&amp;nbsp; | FB_CSCR_WS(0x2) // ...after 2 wait states&lt;/P&gt;
&lt;P&gt;&amp;nbsp; | FB_CSCR_ASET(2) // assert chip select on 2nd clock edge after address&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; // Chip select mask register&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; FB_CSMR0 = FB_CSMR_BAM(0x0) //Set base address mask for 64K address space&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; | FB_CSMR_V_MASK&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; // Chip select address register&lt;/P&gt;
&lt;P&gt;&amp;nbsp; FB_CSAR0 = (unsigned int)&amp;amp;A2D_CPLD_START_ADDRESS; //Set Base address&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;
&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;void flexbus_read_card_info() {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; volatile uint16_t raw_ID;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; _dcache_disable(); // see &lt;/SPAN&gt;&lt;A class="jive-link-thread-small" data-containerid="2023" data-containertype="14" data-objectid="306380" data-objecttype="1" href="https://community.freescale.com/thread/306380" rel="nofollow noopener noreferrer" target="_blank"&gt;https://community.freescale.com/thread/306380&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; raw_ID = (*(uint16_t*)(&amp;amp;A2D_CPLD_START_ADDRESS));&lt;/P&gt;
&lt;P&gt; printf("Raw ID: %d\n", raw_ID);&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The task runs flexbus_init, then flexbus_read_card_info. Whatever I do, raw_ID seems to come out as 40960, i.e. 0xa000. The value should actually be 0x81 (which is stored in the CPLD).&lt;/P&gt;&lt;P&gt;Can anyone help me understand why this might be?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also noticed in the bsp_twrk60f120m code, in init_hw.c it calls a function _bsp_flexbus_mram_setup which also sets up chip select 0; I have tried commenting out this function call but it makes no difference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Oct 2014 18:47:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-flexbus-problems/m-p/363386#M18582</guid>
      <dc:creator>andrewclegg</dc:creator>
      <dc:date>2014-10-29T18:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: K60 flexbus problems</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-flexbus-problems/m-p/363387#M18583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andrew,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are using Flexbus in multiplexed mode.&lt;/P&gt;&lt;P&gt;For the Flexbus 16bits data lines at FB_AD[15:0] pins, it need to set CSCRn[BLS] = 1, more detailed info, please check below picture:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="flexbus.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/40457i25CD26CABCF7BC5E/image-size/large?v=v2&amp;amp;px=999" role="button" title="flexbus.png" alt="flexbus.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And it need to check the hardware connection, for it using 16-bit data port, the CPLD address A0 pin should connect with Flexbus_AD[1] pin.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Wish it helps.&lt;BR /&gt;best regards &lt;BR /&gt;Ma Hui&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 06:02:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-flexbus-problems/m-p/363387#M18583</guid>
      <dc:creator>Hui_Ma</dc:creator>
      <dc:date>2014-10-30T06:02:13Z</dc:date>
    </item>
    <item>
      <title>Re: K60 flexbus problems</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-flexbus-problems/m-p/363388#M18584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thankyou very much for your quick reply. I forgot that I had commented out the BLS=1, thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We currently have the CPLD Address[15:0] pins connected directly to AD[15:0] through an address latch. Looking in the reference manual &lt;SPAN style="color: #000000; font-family: Tahoma;"&gt;K60P144M150SF3RM.pdf, section 33.4.1.2 says that the address and data lines should be connected from FB_AD0 upwards, however on the next paragraph it says that a 16 bit device connects to FB_AD[16:1]. Do you have any more information or an example schematic on why it starts from FB_AD1 and not FB_AD0? Should the FB_AD0 line be connected to anything?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Tahoma;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Tahoma;"&gt;Many thanks again &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 10:09:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-flexbus-problems/m-p/363388#M18584</guid>
      <dc:creator>andrewclegg</dc:creator>
      <dc:date>2014-10-30T10:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: K60 flexbus problems</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-flexbus-problems/m-p/363389#M18585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We spent the whole day with the logic analyzer and figured out the problem. I'll put the solution here incase someone else has the same problem.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Firstly it was OK to connect addr[15:0] directly to FB_AD[15:0], because our 16-bit CPLD does not use word addressing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem was that in the ChipSelect Multiplexing Control Register (FB_CSPMCR), the group1 multiplex control was set to 1 (FB_CS1) rather than 0 (FB_ALE). This occurs in the MQX init code - hw_init.c, _bsp_flexbus_setup(). Because of this, the address latch enable was not working at all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks anyway for your help, you pushed us in the right direction.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 17:41:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-flexbus-problems/m-p/363389#M18585</guid>
      <dc:creator>andrewclegg</dc:creator>
      <dc:date>2014-10-30T17:41:28Z</dc:date>
    </item>
  </channel>
</rss>

