QSPI chip select question

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

cross mob
Not applicable
Hi all,

I have trying QSPI with iLLD library 1.0.0.0.7. I want using QSPI0 with manually driven CS pin. Here is SPI the initialization code part:

//********************************************************************************
// Function Name : init_SPI
// Author :
// Date :
// Parameters : NONE
// Returns : NONE
// Notes : Initializes the SPI Interface
//********************************************************************************
void init_SPI(void)
{
uint32 i;

/* disable interrupts */
boolean interruptState = IfxCpu_disableInterrupts();


IfxQspi_SpiMaster_Config spiMasterConfig;
IfxQspi_SpiMaster_ChannelConfig spiMasterChannelConfig;

{
/* create module config */
IfxQspi_SpiMaster_initModuleConfig(&spiMasterConfig, &MODULE_QSPI0);



/* set the maximum baudrate */
spiMasterConfig.base.maximumBaudrate = 10000000;


/* ISR priorities and interrupt target */
spiMasterConfig.base.txPriority = ISR_PRIORITY_QSPI0_TX;
spiMasterConfig.base.rxPriority = ISR_PRIORITY_QSPI0_RX;
spiMasterConfig.base.erPriority = ISR_PRIORITY_QSPI0_ER;
spiMasterConfig.base.isrProvider = (IfxSrc_Tos)IfxCpu_getCoreIndex();



/* pin configuration */
const IfxQspi_SpiMaster_Pins pins = {&IfxQspi0_SCLK_P20_11_OUT, /* SCLK */
IfxPort_OutputMode_pushPull,
&IfxQspi0_MTSR_P20_14_OUT, /* MOSI */
IfxPort_OutputMode_pushPull,
&IfxQspi0_MRSTA_P20_12_IN, IfxPort_InputMode_pullDown, /* MISO */
IfxPort_PadDriver_cmosAutomotiveSpeed3 /* pad driver mode */
};
spiMasterConfig.pins = &pins;

/* initialize module */
IfxQspi_SpiMaster_initModule(&g_QspiCpu.drivers.spiMaster, &spiMasterConfig);
}

{
/* create channel config */
IfxQspi_SpiMaster_initChannelConfig(&spiMasterChannelConfig,
&g_QspiCpu.drivers.spiMaster);

/* set the baudrate for this channel */
spiMasterChannelConfig.base.baudrate = 3000000;

const IfxQspi_SpiMaster_Output slsOutput = {
&IfxQspi0_SLSO9_P20_3_OUT,
//NULL_PTR, // if this option is used then got jump to intrisic code part !!!!!
IfxPort_OutputMode_pushPull,
IfxPort_PadDriver_cmosAutomotiveSpeed1};

spiMasterChannelConfig.sls.output.pin = slsOutput.pin;
spiMasterChannelConfig.sls.output.mode = slsOutput.mode;
spiMasterChannelConfig.sls.output.driver = slsOutput.driver;
spiMasterChannelConfig.base.mode.autoCS = 0; // HERE I SET AUTO CS DISABLED, BUT CS STAYS ENABLED!!!!!

/* initialize channel */
IfxQspi_SpiMaster_initChannel(&g_QspiCpu.drivers.spiMasterChannel, &spiMasterChannelConfig);
}

/* init tx buffer area */
for (i = 0; i < SPI_BUFFER_SIZE; i++)
g_QspiCpu.qspiBuffer.spi0RxBuffer = (uint8)(0);

IfxCpu_restoreInterrupts(interruptState);

} //end init_SPI


As you see I set up the autoCS disabled but it was not took effect, CS stays automatically driven. Also if I set NULL_PTR for spiMasterChannelConfig.sls.output.pin, then I get intrisic entry, debugger jumps to here :

( file IfxCpu_Inrtinsics_Gnuc.h )

/** Insert DEBUG instruction
*/
IFX_INLINE void __debug(void)
{
__asm__ volatile ("debug" : : : "memory");
}


What the problem could be please ?

Thank you in advance !

Best regards,
Born
0 Likes
3 Replies
User15256
Level 2
Level 2
10 sign-ins 10 replies posted 5 questions asked
Hello,

I have the exactly same issue, did you manage to fix this?
0 Likes
ldj979
Level 2
Level 2
10 sign-ins 5 replies posted 5 questions asked

Hello,

Also, I have the exactly same issue, How can I handle it?

Regards,

DJ LEE

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

Hi, I think here the nuclear option may be need it, so try to override the CS configuration. For this   you need to write directly in the QSPI registers, do that after SpiMaster_initChannel function , so you can try:

update: in order to make this "hack" to work you need to set the autoCS to "1".

 

	        /* initialize channel */
	        IfxQspi_SpiMaster_initChannel(&g_QspiCpu.drivers.spiMasterChannel, &spiMasterChannelConfig);
	    }
/* let's manually override CS configuration*/
 QSPI0_SSOC.B.OEN = 0x0; // OEN bitfield controls the automatic for each CS
 IfxPort_setPinMode(&MODULE_P20, 3u, IfxPort_Mode_outputPushPullGeneral); // reconfigure the pin as GPIO
// here set the pint at the desired level, high or low
// for example with function IfxPort_setPinHigh()

 

 

0 Likes