SPI driver integration with USB demo example in k22f

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

SPI driver integration with USB demo example in k22f

1,743 次查看
varaprasadvenka
Contributor I

Hi there,

I am trying to merge dSPI edma driver example with USB msd cdc demo app example with k22f evaluation board (ksdk 1.3) and using MQX RTOS

Did hardware related initialization in hardware_init.c

It is not working as expected, program getting continuously resetting or DSPI_DRV_EdmaMasterTransferBlocking function return failure , similar kind of problem facing while trying to merge USB demo app with Internal flash example.

understood that DMA configuration and interrupts has to be configured properly during startup of program for SPI

Can anybody help me on this

标签 (1)
0 项奖励
回复
5 回复数

953 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Is it convenient  for you to attach your project here so that we can try to duplicate your issue and track the cause?

BR

Xiangjun Rong

0 项奖励
回复

953 次查看
varaprasadvenka
Contributor I

Hi Xiangjun Rong,

Thank you for the response,

Im sorry from my network cant upload , but I found that with MQX hello world example application also am not able to integrate the dspi_edma_blocking  master driver example I found that spi master bus frequency going to 15 MHz when tried with integration with USB example but according to our configuration ( when run only driver example) it is about 48 kHz
So thought some configuration related to RTOS has to be done in startup routine ,

If possible please share MQX dspi_edma_blocking master example for k22f if you have any or any suggestions where to look over

Thank you once again

0 项奖励
回复

953 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Vava

If the SPI clock frequency is not what you expected, maybe the code somewhere has changed the SPI clock setting, but we can track the SPI clock source. I suppose you do not set up the MCG, you use the default clock for the core and the peripherals, in the case, the core runs in 25MHz, the bus clock is about 12.5mHz, the SPI use the bus clock as the it's own clock.

You can reduce the clock by setting the BR bits in SPIx_CTARn register.

You can write the register with the code directly:

SPI0_CTAR0&=~(0x0F);

SPI0_CTAR0|=0x08;

The SPI 0 clock will be divided by 512.

I have checked the SPI MQX code, theer is code to set the spi clock frequency:

param = 500000;

    printf ("Changing the baud rate to %d Hz ... ", param);

    if (SPI_OK == ioctl (spifd, IO_IOCTL_SPI_SET_BAUD, &param))

    {

        printf ("OK\n");

    }

    else

    {

        printf ("ERROR\n");

    }

    /* Display baud rate */

    printf ("Current baud rate ... ");

    if (SPI_OK == ioctl (spifd, IO_IOCTL_SPI_GET_BAUD, &param))

    {

        printf ("%d Hz\n", param);

    }

    else

    {

        printf ("ERROR\n");

    }

You can change the param parameter to change the clock setting.

Hope it can help you.

BR

Xiangjun rong

0 项奖励
回复

953 次查看
varaprasadvenka
Contributor I

Thank you for input rong,

But I am using following api to configure Bus and it giving success

edmaDevice.bitsPerSec = TRANSFER_BAUDRATE;

    dspiResult = DSPI_DRV_EdmaMasterConfigureBus(DSPI_MASTER_INSTANCE,

                                                 &edmaDevice,

                                                 &calculatedBaudRate);

the same when integrated with USB device example also returning success but on scope showing 15 MHz seems DMA configuration getting disturbed by Task scheduler even tried with only dspi and commented USB related tasks and initializations but no luck,

      Faced same issue with internal flash application which is working without RTOS means as is by ksdk example while integrating with MQX RTOS example giving failure in similar fashion ,did necessary hardware initializations related to spi or flash while doing integration but not working , and observe same board.c file is being used for clock initializations thinking missing some basic like startup or related need to be modified

Please suggest any precautions or process need to be followed  while integrating non RTOS example like Driver spi master or Internal flash examples to RTOS example

Regards

venkata vara prasad

0 项奖励
回复

953 次查看
varaprasadvenka
Contributor I

Hi Rong,

we made some progress now DSPI_DRV_EdmaMasterTransferBlocking now giving success and able to receive data once (if we comment USB related initializations), by referring to

How To: Using Interrupt Handlers in MQX with KSDK  we installed isr to spi0

but the transfer happening only once and after it is resetting if watch dog enabled.some problem with interrupt configuration while debugging it is not coming out of isr or going to rtos idle task

Any help appreciated

Venkata

0 项奖励
回复