how to set a pin to high at the last n bits of a SPI transfer

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

how to set a pin to high at the last n bits of a SPI transfer

642 Views
momo12
Contributor III

Hi

I need to set a pin to high at the last n bits of a SPI transfer. It can also be CS line of the SPI.

What is the best way of doinf this?

Is there a way to trigger a PWM pulse automatically after starting a SPI transfer?

0 Kudos
2 Replies

492 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,
The SPI Frame Output Trigger (Table 49-12 RM rev7) can be routed to a GPIO pin (TRGMUX_OUTx function).
The GPIO will then be set HIGH at the end of each frame when CS negates.

PCC->PCCn[PCC_PORTA_INDEX ] |= PCC_PCCn_CGC_MASK; /* Enable clock for PORTA */
PORTA->PCR[0] |= PORT_PCR_MUX(7);                 /* Port A0: MUX = ALT7, TRGMUX_OUT3 */
TRGMUX->TRGMUXn[1] = 0x3D000000;                  /* LPSPI1_Frame trigger */

Regards,
Daniel

0 Kudos

492 Views
bjrajendra
Senior Contributor I

Hi Daniel,

I would like to assert a PIN after transferring all bits which is also after CS assertion.

But I can't use the TRGMUX inputs since the port I want to assert is not connected to TRGMUX inputs. 

I also tried waitng till 

while((LPSPI0->SR & LPSPI_SR_FCF_MASK)>>LPSPI_SR_FCF_SHIFT==0) {}

Even I tried to wait for the FCF flag to set. I don't see any change considering by frame length as 7+1 bits

pastedImage_1.png

but, stranges the TCF, FCF, WCF flag will set immeadiately after writing the data into the tranmit buffer though theCS still holds the LOW.

Kindly help in this regard,

Raju

0 Kudos