Manual use of MISO/MOSI pins while in SPI mode

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

Manual use of MISO/MOSI pins while in SPI mode

跳至解决方案
2,532 次查看
filo96
Contributor III

Hello,

I'm using a LPCXpresso55s28 board and this is the first time I use an NXP board.

I'm using this board to communicate with an ADC converter via SPI protocol. The communication is working well and I can read/write registers of this external ADC.

In order to communicate, I'm using FLEXCOMM7 accessible from the P17 connector.

However, one of the functionalities of this board requires to identify if the MISO pin changes status and another functionality requires a change in the MOSI pins status.

I noticed I can't route an SPI pin together with a PIO pin, so I think that I can't manually handle GPIO_PinWrite() and GPIO_PinRead() on MOSI and MISO pins.

Is it correct? Is there a workaround to solve this?

 

Thank you.

标签 (2)
标记 (4)
0 项奖励
回复
1 解答
2,468 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I think it is okay to use FC7 as SPI master to communicate with external ADC.

This is the FC7 pin assignment:

PIO0_20   FC7_MOSI

PIO0_21   FC7_SCK

PIO0_19   FC7_MISO

 PIO1_20  FC7_SSEL1

All of them are connected to P17.

Regarding the logic reading of the SPI signal pin, I suppose that you can read the GPIO input register directly even if the pin are assigned as SPI instead of GPIO pins.

Hope it can help you

BR

Xiangjun Rong

 

 

在原帖中查看解决方案

0 项奖励
回复
4 回复数
2,474 次查看
filo96
Contributor III

Firstly, I want to thank you for your answer.

I'd like to clarify that FLEXCOMM7 is as follows:

  • MOSI - PIO0_20
  • SCK - PIO0_21
  • MISO - PIO0_19
  • SSEL1 - PIO1_20 (I use this pin manually, not connected to the SPI driver).

And it's accessible from the connector P17 too.

I configured these pins by using the Pins configurator of MCUXpresso IDE.

 

My doubt regards the possibility to read/write the status of MISO/MOSI respectively, in order to exploit some of the extra features of my external ADC, as well as the SPI communication.

 

EDIT: I'm using an AD7124-8 AD converter.

0 项奖励
回复
2,469 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I think it is okay to use FC7 as SPI master to communicate with external ADC.

This is the FC7 pin assignment:

PIO0_20   FC7_MOSI

PIO0_21   FC7_SCK

PIO0_19   FC7_MISO

 PIO1_20  FC7_SSEL1

All of them are connected to P17.

Regarding the logic reading of the SPI signal pin, I suppose that you can read the GPIO input register directly even if the pin are assigned as SPI instead of GPIO pins.

Hope it can help you

BR

Xiangjun Rong

 

 

0 项奖励
回复
2,440 次查看
filo96
Contributor III

I made some tests using FC7.

  1. DMA controller disabled on SPI + FC7_MISO used with GPIO_PinRead(GPIO,0,19) seems reading a square wave, despite is part of the SPI peripheral.
  2. DMA controller enabled on SPI + FC7_MISO used with GPIO_PinRead(GPIO,0,19) works too
  3. A manual write of FC7_MOSI doesn't work

So I can confirm what you said.

I used GPIO_PinRead() because it seems to read the GPIO input register, so I used this high level function.

 
标记 (4)
0 项奖励
回复
2,521 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

HI,

Based on LPC5528-EVK board, you want to use the FLEXCOMM7 as SPI module.

xiangjun_rong_0-1680827422801.png

 

This is the pin assignment:

PIO1_2   FC7_SCK

PIO1_3  FC7_MISO

PIO0_26   FC7_MOSI

PIO1_1   FC7_SSEL1

 

In the pin_mux.c in SDK project, I suppose you can add the api function so that  you can configure the pin as FC7 SPI pin.

 

For the PIO1_1, when the func is 5, the pin will function as HS_SPI_SSEL1

xiangjun_rong_1-1680828584341.png

So you can use the code to assign the FUNC as 5

#define IOCON_PIO_FUNC5 5

CLOCK_EnableClock(kCLOCK_Iocon);

const uint32_t port1_pin1_config = (/* Pin is configured as HS_SPI_SSEL1 */
IOCON_PIO_FUNC5 |
/* No addition pin function */
IOCON_PIO_MODE_INACT |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);

IOCON_PinMuxSet(IOCON, 1U, 1U, port1_pin1_config);

 

Pls follow up the above line to configure the other pins such as PIO1_2, PIO1_3 and PIO0_26

BTW, you can not use GPIO_PinWrite()/GPIO_PinRead(), they are used to write or read a pin logic only when you have configure the pin as GPIO function.

Hope it can help you

BR

XiangJun Rong

 

 

 

 

0 项奖励
回复