SPI2 fopen hangs on TWRPXN20 BSP

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

SPI2 fopen hangs on TWRPXN20 BSP

1,156 Views
rashmindesai
Contributor I

i had TWRPXN20 tower system. for evaluation purpose, i tried to access spi2 with fopen("spi2",NULL) as given in spi memory example.For "spi0:" and "spi1:" fopen() call return success but for "spi2:" and "spi3:" function just hand and never come out  from call.

After long debugging with BSP and PSP code, i found that execution hang at line (202 of spi_pol_dspi.c)  dspi_ptr->MCR &= (~ DSPI_MCR_MDIS_MASK);

of TWRPXN20 BSP code.

I had enable all SPI module in BSP and also recompiled BSP and PSP.

0 Kudos
Reply
4 Replies

897 Views
Martin_
NXP Employee
NXP Employee

What does it mean "hang" ? Does it mean you get bus error upon attempting to execute that line, thus, any IVORn taken ?

Check with your debugger that there exists a TLB entry in the e200z6 MMU for the DSPI_C and DSPI_D modules. These two reside at real address 0xc3f90000 and 0xc3f94000, there must exist MMU TLB entry covering AIPS(1) Bridge A.

897 Views
rashmindesai
Contributor I

Sorry for incomplete description.i am using MQX 3.8 with TWRPXN20 MQX BSP. I have TWRPXN20 tower module with P&E Multilink Universal debugger.

In test application , i had created Main task which open SPI port and do some operation on it. so i open spi port with fopen mqx call. with spi2 and spi3 this call never return, when i pause code execution , it pause in ideal task. so other task execution is going on, but only task opening spi device is get blocked.

To get place where execution blocks, i place breakpoint in spi_pol_dspi.c , _dspi_polled_init() function, and find that at line dspi_ptr->MCR &= (~ DSPI_MCR_MDIS_MASK) (line-202)  , task blocked and did not hit next line break-point.

As per your suggestion i had reviewed core registers after stopping execution with debugger.Also i have attached exported register xml file.

I don't know but i found something strange that MCR register of DSPIA & DSPIB have value 0x4001, while for DSPIC & DSPID all registers are 0x0.

0 Kudos
Reply

897 Views
Martin_
NXP Employee
NXP Employee

I think _dspi_polled_init() function is called by _io_spi_install() in _bsp_enable_card(). (_dspi_polled_install() in MQX 3.8.1) function and not by fopen(). Do you enable SPI2 and SPI3 in user_config.h ?

I don't have MQX 3.8, I use the latest MQX 4.0.

in the TWR-PXN20 user_config.h I enable

#define BSPCFG_ENABLE_SPI2 TRUE

#define BSPCFG_ENABLE_SPI3 TRUE

and build PXN20 MQX libs and some simple application with fopen("spi2:") call.

When I reset and halt the MCU using debugger, I can see default reset value of DSPI_C.MCR = 0x00004001.

Then I start the application executable. After _bsp_enable_card() I can see the DSPI_C.MCR changes to 0x01FF0000. Then in a task I execute:

  f_ptr_spi2 = fopen("spi2:", NULL);

  if(NULL == f_ptr_spi2)

  {

    printf("Error opening SPI2 driver!\n");

    _task_block();

  }

  else printf("SPI2 driver open OK\n");

the "spi2:" device opens without any issue.

I'm afraid the register dump you attached is not very useful for checking the MMU as we can's see from it the e200z6 MMU table. But in default BSP the MMU configuration is OK, so unless you modified it, we can assume it is good.

Try MQX 4.0, I can send you my user_config.h and the application that I verified as being functional, if you wish.

0 Kudos
Reply

897 Views
rashmindesai
Contributor I

Thank you so much Martin. MQX 4.0 release solved almost all SPI related my problems including chip select. i had already downloaded, but not using MQX 4.0 because of TWRPXN20 3.8.0 separate BSP release.

After installing MQX 4.0, i got new problem, when i create new MQX 4.0 basic project, and try to debug application, it just get halted without stopping at main or any of my breakpoint , i had not even modified single line of code. when i halt execution using debugger it says in call stack "suspended User Halt Received" .

This happens only in new project, when i import example application, it works perfectly.

0 Kudos
Reply