SSC ILLD sample code

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

cross mob
leekings
Level 3
Level 3
50 sign-ins 25 replies posted 25 sign-ins

Hello. Infienon team

here are my 2 question.

Q1.

I'm using TC364DP MCU and also using TLE5012B Motor position sensor.

I'm trying to communicate with SSC protocol, it doesn't workl well.

And i'm  using ILLD example code, but i can't find SSC example in ILLD.

i think MPS and MCU are both infineon product, so i think there is sample code.

can you give sample code? help me.

 

Q2.

If you doesn't have TLE5012's ILLD code or sample code, i have anther question.

I implemented communication via QSPI ILLD module.

But SSC's protocol is different to SPI communication, so i can't get exact data.

i want to know how  QSPI module works.

here is my question.

If QSPI module's RX pin get data and RX buffer is filled, then RX ISR is called even though QSPI module doesn't work?

the topology is below picture. MCU's MOSI and MISO is connected to same node(P6111) .

leekings_0-1672282805784.png

so, when i try to communicate via ILLD QSPI module, my sending command is returned via nodeP6111. i don't know how to implement via ILLD QSPI module.

can you help me to implement SSC communication via QSPI ILLD module?

 

thank you.

 

 

0 Likes
7 Replies
Di_W
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 250 solutions authored

For sensor issue, please refer to this thread.

For QSPI, please refer to the demo code.

For SDO and SDI are connected together, that means if you send with SCLK, then you can use DATA to output from the master, if you receive with SCLK, then you can use DATA to input from the slave.

0 Likes
leekings
Level 3
Level 3
50 sign-ins 25 replies posted 25 sign-ins

Hello. dw.

 

i have more question about QSPI module usage method by using ILLD.

 

i think i can implement SSC communication by using QSPI module. here is my method.

 

1. set QSPI module as Tx mode, and disable Rx pin and send command

2.change QSMPI module as Rx mode(set Tx pin as Rx or disable Tx pin and just using Rx pin

3. get data

 

so, i made samle code, but it isnt' work when i assign Rx pin or Tx pin as NULL_PTR.

I understand that there are fixed pins that I can use for QSPI Tx and Rx. However, all of these pins are already in use, so I cannot allocate them. Therefore, I allocated NULL_PTR to unused pins. However, if I use this method, the program stops in the IfxQspi_SpiMaster_exchange function.

here is my question.

How can I use the QSPI module exclusively for MOSI (Tx) and MISO (Rx)? Can you provide an example code? The following code is my example code, but it is not working properly. I would like to inquire about what went wrong.

The function in the following code aims to convert the QSPI module between Tx mode and Rx mode.

 

void tx_QSPI1_Master(void)
{
/* QSPI1 */
IfxQspi_SpiMaster_initModuleConfig(&spiMasterConfig[1], &MODULE_QSPI1); /* Initialize it with default values */

spiMasterConfig[1].base.mode = SpiIf_Mode_master;
spiMasterConfig[1].base.maximumBaudrate = 4000000;

// qspi1_m_init_pins();

// IfxPort_setPinMode(&MODULE_P10, 1,IfxPort_Mode_outputPushPullAlt2);

const IfxQspi_SpiMaster_Pins qspi1_pins = {
&IfxQspi1_SCLK_P10_2_OUT, IfxPort_OutputMode_pushPull, /* SCLK Pin (CLK) */
&IfxQspi1_MTSR_P10_3_OUT, IfxPort_OutputMode_pushPull, /* Master Transmit Slave Receive Pin (MOSI) */
NULL_PTR, IfxPort_InputMode_pullDown, /* Master Receive Slave Transmit Pin (MISO) */
0 /* Pad driver mode */
};


spiMasterConfig[1].pins = &qspi1_pins; /* Assign Master Pins */

spiMasterConfig[1].base.txPriority = ISR_PRIORITY_QSPI1_TX;
spiMasterConfig[1].base.rxPriority = ISR_PRIORITY_QSPI1_RX;
spiMasterConfig[1].base.erPriority = ISR_PRIORITY_QSPI1_ER;
spiMasterConfig[1].base.isrProvider = IfxSrc_Tos_cpu0;

/* Initialize the QSPI Master module using the user configuration */
IfxQspi_SpiMaster_initModule(&g_spiMaster[1], &spiMasterConfig[1]);
}

void rx_QSPI1_Master(void)
{
/* QSPI1 */
IfxQspi_SpiMaster_initModuleConfig(&spiMasterConfig[1], &MODULE_QSPI1); /* Initialize it with default values */

spiMasterConfig[1].base.mode = SpiIf_Mode_master;
spiMasterConfig[1].base.maximumBaudrate = 4000000;

// qspi1_m_init_pins_rx();//set port as output pin

// IfxPort_setPinMode(&MODULE_P10, 1, IfxPort_Mode_inputPullUp);

const IfxQspi_SpiMaster_Pins qspi1_pins = {
&IfxQspi1_SCLK_P10_2_OUT, IfxPort_OutputMode_pushPull, /* SCLK Pin (CLK) */
NULL_PTR, IfxPort_InputMode_pullDown, /* Master Transmit Slave Receive Pin (MOSI) */
&IfxQspi1_MRSTA_P10_1_IN, IfxPort_InputMode_pullDown, /* Master Receive Slave Transmit Pin (MISO) */
0 /* Pad driver mode */
};
spiMasterConfig[1].pins = &qspi1_pins; /* Assign Master Pins */

spiMasterConfig[1].base.txPriority = ISR_PRIORITY_QSPI1_TX;
spiMasterConfig[1].base.rxPriority = ISR_PRIORITY_QSPI1_RX;
spiMasterConfig[1].base.erPriority = ISR_PRIORITY_QSPI1_ER;
spiMasterConfig[1].base.isrProvider = IfxSrc_Tos_cpu0;

/* Initialize the QSPI Master module using the user configuration */
IfxQspi_SpiMaster_initModule(&g_spiMaster[1], &spiMasterConfig[1]);
}

0 Likes
Di_W
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 250 solutions authored

https://github.com/Infineon/AURIX_code_examples/blob/master/code_examples/SPI_CPU_1_KIT_TC397_TFT/SP...

Please first refer to this SPI example code, if you make it work, then migrate to P10.2/3.

Tx and Rx can be enabled together, just to set a flag TX_DONE, if the flag is set , then Rx interrupt is  enabled. The procedure is like below:

 

Send Data

Enable Rx INT

Receive Data

Disable Rx INT

Send Data

...

0 Likes
leekings
Level 3
Level 3
50 sign-ins 25 replies posted 25 sign-ins

Hello. i tried above method, and it still doesn't works.

i made flag and add it to interrupt function.

/* QSPI1 ISR */
void qspi1_Tx_ISR(void)
{
IfxCpu_enableInterrupts();
if(1==TX_DONE)
{
IfxQspi_SpiMaster_isrTransmit(&g_spiMaster[1]);
}
else
{
}

}
void qspi1_Rx_ISR(void)
{
IfxCpu_enableInterrupts();
if(1==RX_DONE)
{
IfxQspi_SpiMaster_isrReceive(&g_spiMaster[1]);
}
else
{

}

}

And add TX,RX flag in transmit and receive code. but it doesn't works well.  Still tx command is coming back to rx buffer.

i think even i set flag while i sending command by using enabled Transmit interrupt , disabled Receive interrupt, tx command is stored in rx buffer because of circut(MISO/MOSI is connected) and Rx buffer is storing it and return data when Rx interrupt called.

what should i modify more? please help me.

 

TX_DONE = 1;
RX_DONE = 0;
while (IfxQspi_SpiMaster_getStatus(&g_spiMasterChannel[1]) == SpiIf_Status_busy) {};
IfxQspi_SpiMaster_exchange(&g_spiMasterChannel[1], &g_tx_L_POS_u16[spi_num], &g_rx_L_POS_u16[spi_num][3], datalenth); //send command


// rx_QSPI1_Master();//set datapin as rx pin

// int data_num = g_tx_L_POS_u16[spi_num]&&0x000F; // get the number of data

TX_DONE = 0;
RX_DONE = 1;


for(int i=0; i<3;i++)
{
while (IfxQspi_SpiMaster_getStatus(&g_spiMasterChannel[1]) == SpiIf_Status_busy) {};
IfxQspi_SpiMaster_exchange(&g_spiMasterChannel[1], &g_tx_L_POS_u16[5], &g_rx_L_POS_u16[spi_num][i], datalenth);//g_tx_L_POS_u16[5] is 0x000u
}

0 Likes
Di_W
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 250 solutions authored
0 Likes
leekings
Level 3
Level 3
50 sign-ins 25 replies posted 25 sign-ins

Hello. dw.

 

i read your links and  solved my problem with refering below link.

https://community.infineon.com/t5/AURIX/TC375-QSPI0-CS-Manually-Selection-Software-control-using-iLL...

 

my problem was 'chip select' signal was not keep low state while communication to pheriperal.

so i refered above linke and solved it.(set autoCS as '1', and set 'QSPI1_SSOC.B.OEN = 0' works.

 

but i have one more question.

i tried to set pin status with ' IfxPort_setPinState(&MODULE_P10, 0, IfxPort_State_low);' function.

but it doesn't works. so i used below code for directly access to register.

P10_IOCR0.B.PC0 = 0x10;
P10_OUT.B.P0 = 0;

why' 'IfxPort_setPinState()' function doesn't works?

 

0 Likes
Di_W
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 250 solutions authored

Hi leekings, to avoid the interference by other part of code, please try to use a clean project to test P10.0.

Below GPIO code is helpful.

0 Likes