TC375 QSPI0 CS Manually Selection(Software control) using iLLD

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
ldj979
Level 2
Level 2
10 sign-ins 5 replies posted 5 questions asked

Hi Team,

A problem occurred during implementation to manually control the CS of QSPI0. I set the member variable called autocs to 0 to manually manipulate it, but it didn't work.

Even though I set the QSPI0_SSOC.B.OEN register to 0x0 with reference to other subscriptions, CS works automatically still.

To check one thing, I set the CS pin in the init function to pinState setHigh in the in state, and even though the test was carried out, the pinState setLow continues to occur during QSPI Transfer operation.

what's wrong in my code?

Regards,

DJ LEE

 

/*********************************************************************************************************************/
/*-----------------------------------------------------Includes------------------------------------------------------*/
/*********************************************************************************************************************/
#include <Aurix_func.h>

/*********************************************************************************************************************/
/*-------------------------------------------------Global variables--------------------------------------------------*/
/*********************************************************************************************************************/
qspiComm g_qspi0;

/*********************************************************************************************************************/
/*-------------------------------------------------Declaration-------------------------------------------------------*/
/*********************************************************************************************************************/
void initQSPI0Master(void);
void initQSPI0MasterChannel(void);
void initQSPI0MasterBuffers(void);
//void enableQSPI0(void);

/*********************************************************************************************************************/
/*---------------------------------------------Function Implementations----------------------------------------------*/
/*********************************************************************************************************************/
IFX_INTERRUPT(master0TxISR, 0, ISR_PRIORITY_MASTER_TX);
IFX_INTERRUPT(master0RxISR, 0, ISR_PRIORITY_MASTER_RX);
IFX_INTERRUPT(master0ErISR, 0, ISR_PRIORITY_MASTER_ER);

/* Function to initialize the Master TxISR */
void master0TxISR()
{
IfxCpu_enableInterrupts();
IfxQspi_SpiMaster_isrTransmit(&g_qspi0.spiMaster);
}

/* Function to initialize the Master RxISR */
void master0RxISR()
{
IfxCpu_enableInterrupts();
IfxQspi_SpiMaster_isrReceive(&g_qspi0.spiMaster);
}

/* Function to initialize the Master ErrorISR */
void master0ErISR()
{
IfxCpu_enableInterrupts();
IfxQspi_SpiMaster_isrError(&g_qspi0.spiMaster);
}

/* Function to initialize the Master QSPI0 */
void initQSPI0Master(void)
{
IfxQspi_SpiMaster_Config spiMasterConfig; /* Define a Master configuration */

IfxQspi_SpiMaster_initModuleConfig(&spiMasterConfig, QSPI0_MASTER); /* Initialize it with default values */

spiMasterConfig.base.mode = SpiIf_Mode_master; /* Configure the mode */

/* Select the port pins for communication */
const IfxQspi_SpiMaster_Pins qspi0MasterPins = {
&IfxQspi0_SCLK_P20_11_OUT, IfxPort_OutputMode_pushPull, /* SCLK Pin (CLK) */
&IfxQspi0_MTSR_P20_14_OUT, IfxPort_OutputMode_pushPull, /* MasterTransmitSlaveReceive pin (MOSI) */
&IfxQspi0_MRSTA_P20_12_IN, IfxPort_InputMode_pullDown, /* MasterReceiveSlaveTransmit pin (MISO) */
IfxPort_PadDriver_cmosAutomotiveSpeed3 /* Pad driver mode */
};
spiMasterConfig.pins = &qspi0MasterPins; /* Assign the Master's port pins */

/* Set the ISR priorities and the service provider */
spiMasterConfig.base.txPriority = ISR_PRIORITY_MASTER_TX;
spiMasterConfig.base.rxPriority = ISR_PRIORITY_MASTER_RX;
spiMasterConfig.base.erPriority = ISR_PRIORITY_MASTER_ER;
spiMasterConfig.base.isrProvider = IfxSrc_Tos_cpu0;

/* Initialize the QSPI Master module */
IfxQspi_SpiMaster_initModule(&g_qspi0.spiMaster, &spiMasterConfig);
}

/* Function to initialize the Master QSPI0 Channel */
void initQSPI0MasterChannel(void)
{
IfxQspi_SpiMaster_ChannelConfig spiMasterChannelConfig; /* Define a Master Channel configuration */

/* Initialize the configuration with default values */
IfxQspi_SpiMaster_initChannelConfig(&spiMasterChannelConfig, &g_qspi0.spiMaster);

spiMasterChannelConfig.base.baudrate = MASTER_CHANNEL_BAUDRATE; /* Set SCLK frequency to 1 MHz */
spiMasterChannelConfig.base.mode.shiftClock = SpiIf_ShiftClock_shiftTransmitDataOnLeadingEdge;
spiMasterChannelConfig.base.mode.clockPolarity = SpiIf_ClockPolarity_idleLow;
spiMasterChannelConfig.base.mode.dataHeading = SpiIf_DataHeading_msbFirst;
spiMasterChannelConfig.base.mode.dataWidth = 8;
spiMasterChannelConfig.base.mode.autoCS = 0;

/* Select the port pin for the Chip Select signal */
const IfxQspi_SpiMaster_Output qspi0SlaveSelect = { /* QSPI1 Master selects the QSPI1 Slave */
&IfxQspi0_SLSO2_P20_13_OUT, IfxPort_OutputMode_pushPull, /* Slave Select port pin (CS) */
IfxPort_PadDriver_cmosAutomotiveSpeed1 /* Pad driver mode */
};
spiMasterChannelConfig.sls.output = qspi0SlaveSelect;

/* Initialize the QSPI Master channel */
IfxQspi_SpiMaster_initChannel(&g_qspi0.spiMasterChannel, &spiMasterChannelConfig);

QSPI0_SSOC.B.OEN = 0x0;
IfxPort_setPinMode(QSPI0_CE, IfxPort_Mode_outputPushPullGeneral);
IfxPort_setPinHigh(QSPI0_CE);
}

/* Function to initialize the Master QSPI0 Buffer */
void initQSPI0MasterBuffers(void)
{
for (volatile int i = 0; i < DATA_TO_TRANSFER; i++)
{
g_qspi0.spiBuffers.spiMasterTxBuffer[i] = 0; /* Fill TX Master Buffer with pattern */
g_qspi0.spiBuffers.spiMasterRxBuffer[i] = 0; /* Clear RX Buffer */
}
}


/* This function initialize the QSPI modules */
void initQSPI(void)
{
/* Initialize the Master */
initQSPI0Master();
initQSPI0MasterChannel();
initQSPI0MasterBuffers();
}

/* This function starts the data transfer */
void transferQSPI0(uint8* Tx, uint8* Rx, uint16 iLength)
{

while(IfxQspi_SpiMaster_getStatus(&g_qspi0.spiMasterChannel) == SpiIf_Status_busy)
{ /* Wait until the previous communication has finished, if any */
}

for (sint16 i =0; i < (sint16)iLength; i++)
{
g_qspi0.spiBuffers.spiMasterTxBuffer[i] = Tx[i];
g_qspi0.spiBuffers.spiMasterRxBuffer[i] = Rx[i];
}

/* Send a data stream through the SPI Master */
IfxQspi_SpiMaster_exchange(&g_qspi0.spiMasterChannel, &g_qspi0.spiBuffers.spiMasterTxBuffer[0], &g_qspi0.spiBuffers.spiMasterRxBuffer[0], (sint16)iLength);
IfxPort_setPinState(LED2, IfxPort_State_toggled);
}

/* Function to QSPI Close */
void deactivateQSPI0(void)
{

}

0 Likes
1 Solution
ugo_8a
Employee
Employee
10 solutions authored 25 sign-ins 25 replies posted

Hi, 

please set autoCS  to "1" ,  and keep the code where you set the OEN to "0" and  pin configuration .

the trick here is that the iLLD library only has two options for the autoCS:

    uint32 autoCS : 1;                  /**< \brief 1 = chip select is controlled by the hardware module or, 0 = by software. */

 so when you set autoCS to 0 , then the CS is controlled by the iLLD library,  the library has two functions inside called activateSlso and deactivateSlso , they are called automatically by the library to set the CS low or high, in your case I assume you want a "custom" CS , so you can manually control the pin , in this case we need to "cheat" and tell ILLD to use hardware CS but then override this configuration by modifying the OEN register. After this you should be able to control de Pin with your own function.

View solution in original post

0 Likes
1 Reply
ugo_8a
Employee
Employee
10 solutions authored 25 sign-ins 25 replies posted

Hi, 

please set autoCS  to "1" ,  and keep the code where you set the OEN to "0" and  pin configuration .

the trick here is that the iLLD library only has two options for the autoCS:

    uint32 autoCS : 1;                  /**< \brief 1 = chip select is controlled by the hardware module or, 0 = by software. */

 so when you set autoCS to 0 , then the CS is controlled by the iLLD library,  the library has two functions inside called activateSlso and deactivateSlso , they are called automatically by the library to set the CS low or high, in your case I assume you want a "custom" CS , so you can manually control the pin , in this case we need to "cheat" and tell ILLD to use hardware CS but then override this configuration by modifying the OEN register. After this you should be able to control de Pin with your own function.

0 Likes