Writing to Flexbus of MKFN1M0VLL12

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

Writing to Flexbus of MKFN1M0VLL12

405 Views
nicholasstrong
Contributor I

Hey guys,

Been banging my head against this one for about a week now and I think it is about time to reach out for any help willing to be given. Currently I am working on a University project and am attempting to write a word out of the Flexbus to a CPLD & FIFO on a board we have built. It's been a bit of a trial by fire but I am trying to learn as much as I can to go along. Hopefully someone can help point the way for me.

So, anyways, I am trying to write this word to the Flexbus and getting ZERO output. I can toggle a GPIO pin as you will see but as far as getting any response from the Flexbus pins on an oscilloscope it has been just as flat as can be. Ive tried probing data and FB_ALE pin. It should be configured as 16 bit multiplexed. Could anyone take a look and hopefully point me in a direction?

I think it may have something to do with the clock but I am a little overwhelmed when trying to understand how to configure it correctly.

Anyways, I have tried to clean up my code. Take a look:

#include "board.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "fsl_gpio.h"
#include "fsl_flexbus.h"

#define FLEX_START_ADDRESS 0x60000000U
#define CPLDMasterReset 18u //PTC18

void delay(void);


int main(void) {
    /* Init structure for GPIO logic */
    gpio_pin_config_t pin_config = {
            kGPIO_DigitalOutput, 0,};

    /* Init board hardware. */
    BOARD_InitPins();
    BOARD_BootClockRUN();
    BOARD_InitDebugConsole();

    /* Initialize Flexbus */
    flexbus_config_t flexbusUserConfig;
    FLEXBUS_GetDefaultConfig(&flexbusUserConfig);  //Gets the default configuration.
    //Configure some parameters when using MRAM
    flexbusUserConfig.waitStates            = 2U;                  //Wait 2 states
    flexbusUserConfig.portSize = kFLEXBUS_2Bytes;
    flexbusUserConfig.byteLaneShift = kFLEXBUS_Shifted;
    flexbusUserConfig.chipBaseAddress       = FLEX_START_ADDRESS;  //address for using FlexBus
    flexbusUserConfig.chipBaseAddressMask   = 7U;                  //512 kilobytes memory size
    FLEXBUS_Init(FB, &flexbusUserConfig);  //Initializes and configures the FlexBus module
    int32_t *address = (int32_t *)FLEX_START_ADDRESS;

    // Send FIFO reset signal to CPLD
    GPIO_PinInit(GPIOC, CPLDMasterReset, &pin_config);
    GPIO_TogglePinsOutput(GPIOC, 1u << CPLDMasterReset);
    delay();
    GPIO_TogglePinsOutput(GPIOC, 1u << CPLDMasterReset);
    delay();

    // Write 16 bits to Flexbus
    uint16_t testdata = 0xFFFF;
    *(address) = testdata;

    for(;;) { /* Infinite loop to avoid leaving the main function */
        __asm("NOP"); /* something to use as a breakpoint stop while looping */
    }
}

void delay(void)
{
    volatile uint32_t i = 0;
    for (i = 0; i < 100000; ++i)
    {
        __asm("NOP"); /* delay */
    }
}

Thank you for your time

Labels (2)
0 Kudos
1 Reply

300 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

I would recommend customer to check Flexbus demo within Kinetis® 100MHz Rev 2 Example Projects(REV 1.0).

There will provide more clear view about Flexbus setting.

Wish it helps.


Have a great day,
Ma Hui

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

0 Kudos