Error opening SPI driver in spi_master example of MQX_V5 IAR

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

Error opening SPI driver in spi_master example of MQX_V5 IAR

1,168 Views
Satish_Davare
Contributor II

Hello,

I am using MQX_V5 for IAR IDE. I am using MQX package provided example spi_master.

I am using our own development board. External Data flash is connected to SPI3.

I did following changes.

1. added definitions of pins in BOARD_InitPins(); of BSP.  these are right, because same pins working with NXP bare metal examples. 

 

2.Enable SPI in user_conifg.h

#define BSPCFG_ENABLE_LPSPI3 1

 

3. Still TEST_CHANNEL  is not assigned by "spi3:" by following code snipped.

#elif BSP_SPI_MEMORY_CHANNEL == 3

#if ! BSPCFG_ENABLE_SPI3
#error This application requires BSPCFG_ENABLE_SPI3 defined non-zero in user_config.h. Please recompile kernel with this option.
#else
#define TEST_CHANNEL "spi3:"
#endif

4. so, I added #define BSPCFG_ENABLE_SPI3 1  in user_conifg.h

Now, it is assigned "spi3:" to TEST_CHANNEL  

3. but finally at following code, not opening port. Execution reach at task_block() line. 

 /* Open the SPI driver */
spifd = fopen (TEST_CHANNEL, NULL);
_io_printf("channel = %d",channel);
if (NULL == spifd)
{
printf ("Error opening SPI driver!\n");
_time_delay (200L);
_task_block ();

Is there any settings required to Open SPI Port?

 

 

 

0 Kudos
3 Replies

1,150 Views
danielchen
NXP TechSupport
NXP TechSupport

I would suggest trace spifd = fopen (TEST_CHANNEL, NULL);

Then you can see why the fopen returns a invalid pointer.

 

Regards

Daniel

0 Kudos

1,128 Views
Satish_Davare
Contributor II

Thanks danielchen,

Thanks for your guidance.

I traced it. fopen is taking "spi3:". but in init.bsp.c file, there is following code.

IF_FEATURE_ENABLED( BSPCFG_ENABLE_LPSPI3, _io_spi_install("lpspi3:", &_bsp_spi3_init); )

here, driver name is "lpspi3:". So, SPI3 driver was not installed.

I changed #define TEST_CHANNEL "spi3:" to  #define TEST_CHANNEL "lpspi3:"

 

Now, driver is installed and SPI is working. This issue is resolved. 

Just for for my knowledge, can you please tell me

is this right way of modification? can we interchange SPI and LPSPI like this? is there difference between SPI and LPSPI drivers?

 

 

 

0 Kudos

1,118 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi 

 

I would suggest you check the MCU reference manual.  whether the spi3  is a low power spi ?  if yes, and it is working, I think it is right.

The difference between spi and lpspi is , lpspi supports low power feature.  and spi not.

 

Regards

Daniel

0 Kudos