SDK MKV10 DSPI Chip Select Problem

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

SDK MKV10 DSPI Chip Select Problem

1,730 Views
haojianxu
Contributor I

I have a problem configuring DSPI chip selection by using SDK 1.30. 

1. I am using MKV10Z64VLF7 microprocessor DSPI to connect 3 SPI devices.

2. I configured Pin-41,Pin-45, and Pin-46 as SPI0_PCS0, SPI0_PCS1, and SPI0_PCS2 in SDK.

3. At fsl_dspi component, Chip selection configuration, I get a error for Pin-45 as

ERROR: The routing parameters are not specified correctly, there are several peripherals matching the 'alias' query.

4. The error looks like related to Pin-45 can be configured either SPI0_PCS1 or SPI0_PCS0. 

 

Is this a SDK bug ? Any solution to bypass this problem?

 

Thanks,

 

HJ

 

Labels (1)
0 Kudos
Reply
9 Replies

1,495 Views
isaacavila
NXP Employee
NXP Employee

Hello HJ,

This is a known issue in PEx where same pin has two different alternatives that work for same peripheral, in this case PTD4 (pin 45) can be used as SPI0_PCS0 and SPI0_PCS1.

You can check this post where same issue applies for ADC pins: Using ADC0_SE4a/ADC0_SE5a/ADC0_SE6a on MK02FN64 with fsl_adc16 

As a workaround, you can select any other SPI pin instead of PTD4 and then replace this pin for PTD4's reference (as expressed in previous thread).

I hope this can help you!

Best Regards,

Isaac

0 Kudos
Reply

1,495 Views
haojianxu
Contributor I

Hi Isaacavila,

Thank you for your help. I read the link you mentioned. To mimic the process, what I did as

 

1. In component fsl_dspi, "Chip selection configurations" I select Pin-41,Pin-41(instead of pin-45), and Pin-46 as 3 chip selects and no errors.

2. Generated the code. In file dspiCom1.c, I cannot find pin definition to switch back to Pin-45. Do you know which file I should modify to use the correct chip select pin ?

 

HJ

--------------------------------------------------------------------------------

const dspi_master_user_config_t dspiCom1_MasterConfig0 = {

.whichCtar = kDspiCtar0,

.isSckContinuous = false,

.isChipSelectContinuous = false,

.whichPcs = kDspiPcs0,

.pcsPolarity = kDspiPcs_ActiveLow,

};

 

const dspi_master_user_config_t dspiCom1_MasterConfig1 = {

.whichCtar = kDspiCtar0,

.isSckContinuous = false,

.isChipSelectContinuous = false,

.whichPcs = kDspiPcs1,

.pcsPolarity = kDspiPcs_ActiveLow,

};

 

const dspi_master_user_config_t dspiCom1_MasterConfig2 = {

.whichCtar = kDspiCtar0,

.isSckContinuous = false,

.isChipSelectContinuous = false,

.whichPcs = kDspiPcs2,

.pcsPolarity = kDspiPcs_ActiveHigh,

};

0 Kudos
Reply

1,495 Views
isaacavila
NXP Employee
NXP Employee

Hello HJ,

First of all, in init_spi_pins you need to select the proper alternative for PTD4 that corresponds to SPI0_PCS1:

  /* Affects PORTD_PCR4 register */
  PORT_HAL_SetMuxMode(PORTD,4UL,kPortMuxAlt2);

And then, when you want to send any data to slave connected to SPI0_PCS1, you must use the dspi_master_user_config_t structure that corresponds to SPI0_PCS1:

DSPI_HAL_WriteDataMastermodeBlocking(SPI0, &dspiCom1_MasterConfig1, buffer);

And you will be able to send data to slave connected at SPI0_PCS1.

I hope this helps!

Regards,

Isaac

0 Kudos
Reply

1,495 Views
haojianxu
Contributor I

Hi Isaac,

I cannot switch hardware pin-45 to other pins since the boards have been done. Given this case, only I need is a work around to use pin-45 as PCS1.

Based on that ADC link you mentioned, seems I can fool the tool by selecting other pin e.g. Pin-41, my PCS0, as PCS1. Then after generated code, change back to Pin-45.

I am using SDK 1.3 to initialize all peripherals.

 

Any solution for this situation ?

 

Thanks,

 

HJ

0 Kudos
Reply

1,495 Views
isaacavila
NXP Employee
NXP Employee

Hello HJ,

Pin-45 is PTD4, so previous solution was provided to use PTD4 (pin 45) as PCS1 pin for SPI0 module.

If you want to use PEx to configure this pin as SPI0_PCS1, just configure Chip select pins as follows:

Chip Select configuration.jpg

And then, in pin_mux component, select PTD4 pin for chip select 1:

2016-09-08_16-04-17.jpg

And everything will be configured correctly.

I hope this helps!

Best Regards,

Isaac

0 Kudos
Reply

1,495 Views
haojianxu
Contributor I

Hi Isaac,

This is exact my current setup. My only question I have is

In PE, fsl_dspi component, since "Chip select configuration" #0 and #1 are the same pin. Does this setup conflict with pin-mux selection ? if not, why we need do "chip select configuration"?  Can we just uncheck this box ?

 

Thanks,

Haojian

0 Kudos
Reply

1,495 Views
isaacavila
NXP Employee
NXP Employee

Hello HJ,

Indeed, this chip selection configuration table is used to select which pins will act as PCS and it populates the pin-mux section, however, as PTD4 cannot be selected due PEx's known issue, you cannot use the pin_mux section to do this. So you can uncheck this box.

Only be sure that hardware init does contain pin initialization for SPI pins.

I hope this can help!

Regards,

Isaac

0 Kudos
Reply

1,495 Views
haojianxu
Contributor I

Hi Isaac,

Here are my understandings based on your comments:

 

1. component fsl_dspi, uncheck "Chip select pin" section.

2. component pin_mux:PinSettings, I selected Pin-41,Pin-45,Pin-46 as "Chip select 0,1,2".

 

In fact, I checked "pin_mux.c" file. It looks like whatever fsl_dspi configurations are, pin_mux.c will following "component pin_mux:PinSettings" not fsl_dspi.

Let me know if I misunderstanding anything.

 

HJ

0 Kudos
Reply

1,495 Views
isaacavila
NXP Employee
NXP Employee

Hello HJ,

Yes, you are right, as long as every pin is configured correclty and SPI master has different configuration to use each PCS signal, you will be able to manage transaction for every PCS pin (PCS0, PCS1, PCS2).

I hope this helps!

Regards,

Isaac

0 Kudos
Reply