David OUATTARA

FlexioSPI on iMXRT1050

Discussion created by David OUATTARA on Dec 11, 2019
Latest reply on Jan 8, 2020 by David OUATTARA

Hello,

 

I have a system composed with an external ADC and the iMXRT. They communicate via FlexioSPI.

The SCK signal is delivered by the mcu when a rising edge is detected on the SPI_SDI FlexIO pin. 

I need to insert a delay between the rising edge on SDI pin and the generation of the clock on SCK pin, and do it the following way:

- The timer1 (16 bits) is triggered by the rising edge on SPI_SDI FlexIO pin

- Then this timer1 counts until a value of 500 cycles then stops counting/decounting

- Timer0 is triggered when Timer1 is reset and the SPI_CLK signal is output on the pin

 

When using the following code to send the timer1 status (1 on 0) on the SDO pin, I can see that

- SCK is always high, meaning timer0 is never triggered

- SDO pin tries to go low and goes back high

 

Can you help me on this?

 

Regards


/* 2. Configure the shifter 1 for rx VCELL1. */
shifterConfig.timerSelect = base->timerIndex[0];
shifterConfig.pinConfig = kFLEXIO_PinConfigOutputDisabled;
shifterConfig.pinSelect = base->SDIPinIndex;
shifterConfig.pinPolarity = kFLEXIO_PinActiveHigh;
shifterConfig.shifterMode = kFLEXIO_ShifterModeReceive;
shifterConfig.inputSource = kFLEXIO_ShifterInputFromPin;
shifterConfig.shifterStop = kFLEXIO_ShifterStopBitDisable;
shifterConfig.shifterStart = kFLEXIO_ShifterStartBitDisabledLoadDataOnEnable;
if (masterConfig->phase == kFLEXIO_SPI_ClockPhaseFirstEdge)
{
shifterConfig.timerPolarity = kFLEXIO_ShifterTimerPolarityOnPositive;
}
else
{
shifterConfig.timerPolarity = kFLEXIO_ShifterTimerPolarityOnNegitive;
}

FLEXIO_SetShifterConfig(base->flexioBase, base->shifterIndex[1], &shifterConfig);

/*3. Configure the timer 0 for . VCELL2 */
timerConfig.triggerSelect = FLEXIO_TIMER_TRIGGER_SEL_PININPUT(base->SDIPinIndex); 
timerConfig.triggerPolarity = kFLEXIO_TimerTriggerPolarityActiveLow;
timerConfig.triggerSource = kFLEXIO_TimerTriggerSourceInternal;
timerConfig.pinConfig = kFLEXIO_PinConfigOutput;
timerConfig.pinSelect = base->SDOPinIndex; 
timerConfig.pinPolarity = kFLEXIO_PinActiveLow; 
timerConfig.timerMode = kFLEXIO_TimerModeSingle16Bit;
timerConfig.timerOutput = kFLEXIO_TimerOutputZeroNotAffectedByReset;
timerConfig.timerDecrement = kFLEXIO_TimerDecSrcOnFlexIOClockShiftTimerOutput;
timerConfig.timerReset = kFLEXIO_TimerResetNever;
timerConfig.timerDisable = kFLEXIO_TimerDisableOnTimerCompare;
timerConfig.timerEnable = kFLEXIO_TimerEnableOnTriggerBothEdge; 
timerConfig.timerStop = kFLEXIO_TimerStopBitEnableOnTimerDisable;
timerConfig.timerStart = kFLEXIO_TimerStartBitEnabled;
timerConfig.timerCompare = 500;
FLEXIO_SetTimerConfig(base->flexioBase, base->timerIndex[1], &timerConfig);


/*3. Configure the timer 0 for SCK. VCELL1 */
timerConfig.triggerSelect = FLEXIO_TIMER_TRIGGER_SEL_TIMn(base->timerIndex[1]); 
timerConfig.triggerPolarity = kFLEXIO_TimerTriggerPolarityActiveLow;
timerConfig.triggerSource = kFLEXIO_TimerTriggerSourceInternal;
timerConfig.pinConfig = kFLEXIO_PinConfigOutput;
timerConfig.pinSelect = base->SCKPinIndex;
timerConfig.pinPolarity = kFLEXIO_PinActiveLow;
timerConfig.timerMode = kFLEXIO_TimerModeDual8BitBaudBit;
timerConfig.timerOutput = kFLEXIO_TimerOutputZeroNotAffectedByReset;
timerConfig.timerDecrement = kFLEXIO_TimerDecSrcOnFlexIOClockShiftTimerOutput;
timerConfig.timerReset = kFLEXIO_TimerResetNever;
timerConfig.timerDisable = kFLEXIO_TimerDisableOnTimerCompare;
timerConfig.timerEnable = kFLEXIO_TimerEnableOnTriggerBothEdge;
timerConfig.timerStop = kFLEXIO_TimerStopBitEnableOnTimerDisable;
timerConfig.timerStart = kFLEXIO_TimerStartBitEnabled;

timerDiv = srcClock_Hz / masterConfig->baudRate_Bps;
timerDiv = timerDiv / 2 - 1;

timerCmp = ((uint32_t)(masterConfig->dataMode * 2 - 1U)) << 8U;
timerCmp |= timerDiv;

timerConfig.timerCompare = timerCmp;

FLEXIO_SetTimerConfig(base->flexioBase, base->timerIndex[0], &timerConfig);

Outcomes