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);
Hi
Could you help to provide the target ADC device datasheet?
It looks like to add a start bit at SPI_TX pin.
Have a great day,
Mike
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Hi,
The ADC is ADS1222, you can find the datasheet on the following link:
http://www.ti.com/lit/ds/sbas314b/sbas314b.pdf
On the system, we have
- 2 ADS1222 components that send their data to the MCU on SDI1 and SDI2
- At the end of conversion, these ADC send a falling edge on the SDI1 or SDI2 pin towards the MCU
- When receivinf the falling edge on SDI1 pin, the FlexIO starts sending the data clock on the SCK pin.
- Both ADC components synchronise on the SCK signal to send their data
Current configuration :
What we would like to do:
ADS1222 datasheet says that the data from 2 components in parallel can be de-synchronized by 0,8ms.
So we want to insert a delay of 0,8ms between the falling edge on SDI1 and the beginning of the clock signals on SCK.
We try to do it by inserting timerIndex[1] of the FlexIO so that, when t0=0ms :
Thanks for helping
Regards
David
Hi David,
I checked below timer1 configuration, as customer mentioned the timerIndex[1] counts down during 0,8ms and then triggers timerIndex[0], I made below modification about the timer1 configuration for your reference:
/*3. Configure the timer 1 for . VCELL2 */
timerConfig.triggerSelect = FLEXIO_TIMER_TRIGGER_SEL_PININPUT(base->SDIPinIndex);
timerConfig.triggerPolarity = kFLEXIO_TimerTriggerPolarityActiveLow;
timerConfig.triggerSource = kFLEXIO_TimerTriggerSourceInternal;
timerConfig.pinConfig = kFLEXIO_PinConfigOutputDisabled; //kFLEXIO_PinConfigOutput;
timerConfig.pinSelect = 0; //base->SDOPinIndex;
timerConfig.pinPolarity = kFLEXIO_PinActiveLow;
timerConfig.timerMode = kFLEXIO_TimerModeSingle16Bit;
timerConfig.timerOutput = kFLEXIO_TimerOutputZeroNotAffectedByReset;
timerConfig.timerDecrement = kFLEXIO_TimerDecSrcOnFlexIOClockShiftTimerOutput;
timerConfig.timerReset = kFLEXIO_TimerResetOnTimerTriggerBothEdge; //kFLEXIO_TimerResetNever;
timerConfig.timerDisable = kFLEXIO_TimerDisableOnTimerCompareTriggerLow; //kFLEXIO_TimerDisableOnTimerCompare;
timerConfig.timerEnable = kFLEXIO_TimerEnableOnTriggerBothEdge;
timerConfig.timerStop = kFLEXIO_TimerStopBitDisabled; //kFLEXIO_TimerStopBitEnableOnTimerDisable;
timerConfig.timerStart = kFLEXIO_TimerStartBitDisabled; //kFLEXIO_TimerStartBitEnabled;
timerConfig.timerCompare = 500;
FLEXIO_SetTimerConfig(base->flexioBase, base->timerIndex[1], &timerConfig);
Wish it helps.
Have a great day,
Mike
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Hello Mike,
Thank you for your support.
I made some changes on your code and it works now, see code below:
/*3. Configure the timer 1 for 0,8ms delay */
timerConfig.triggerSelect = FLEXIO_TIMER_TRIGGER_SEL_PININPUT(base->SDIPinIndex);
timerConfig.triggerPolarity = kFLEXIO_TimerTriggerPolarityActiveHigh;
timerConfig.triggerSource = kFLEXIO_TimerTriggerSourceInternal;
timerConfig.pinConfig = kFLEXIO_PinConfigOutput; //;kFLEXIO_PinConfigOutputDisabled
timerConfig.pinSelect = 0; //base->SDOPinIndex;
timerConfig.pinPolarity = kFLEXIO_PinActiveLow;
timerConfig.timerMode = kFLEXIO_TimerModeSingle16Bit;
timerConfig.timerOutput = kFLEXIO_TimerOutputZeroNotAffectedByReset;
timerConfig.timerDecrement = kFLEXIO_TimerDecSrcOnFlexIOClockShiftTimerOutput;
timerConfig.timerReset = kFLEXIO_TimerResetOnTimerTriggerBothEdge;
timerConfig.timerReset = kFLEXIO_TimerResetOnTimerTriggerEqualToTimerOutput; //kFLEXIO_TimerResetNever;
timerConfig.timerDisable = kFLEXIO_TimerDisableOnTimerCompareTriggerLow;
timerConfig.timerDisable = kFLEXIO_TimerDisableOnPinBothEdge;
timerConfig.timerEnable = kFLEXIO_TimerEnableOnTriggerBothEdge;
timerConfig.timerStop = kFLEXIO_TimerStopBitDisabled; //kFLEXIO_TimerStopBitEnableOnTimerDisable;
timerConfig.timerStart = kFLEXIO_TimerStartBitDisabled; //kFLEXIO_TimerStartBitEnabled;
timerConfig.timerCompare = 400;
FLEXIO_SetTimerConfig(base->flexioBase, base->timerIndex[1], &timerConfig);
Regards
David