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

AURIX™ Forum Discussions

User20495
Level 1
Level 1
Hello,

I'm implementing the example from the iLLD_TC27D.doc so I can use the ASCLIN SPI inteface.

The sendbuffer ist filled with the first eight upper case alphabet letter 'ABCDEFGH'

My problem is that I can't see the values on the oscilloscope. If I use "spiConfig.inputOutput.loopBack = TRUE;" then the values are directly passed into the receive buffer.

Am I missing something obvious?

*EDIT*
This problem is resolved. I had an issue in my code where &MODULE_ASCLIN1 was pointing to the address of &MODULE_ASCLIN2. After fixing this I saw the values on the oscilloscope.
*EDIT*


I'd appreciate any help. Thank you in advance.

Miguel


IfxAsclin_Spi spi;
#define SPI_BUFFER_SIZE 8
uint8 spiTxBuffer[SPI_BUFFER_SIZE];
uint8 spiRxBuffer[SPI_BUFFER_SIZE];

#define IFX_INTPRIO_ASCLIN1_TX 10
#define IFX_INTPRIO_ASCLIN1_RX 11
#define IFX_INTPRIO_ASCLIN1_ER 12

IFX_INTERRUPT(asclin1TxISR, 0, IFX_INTPRIO_ASCLIN1_TX)
{
IfxAsclin_Spi_isrTransmit(&spi);
}

IFX_INTERRUPT(asclin1RxISR, 0, IFX_INTPRIO_ASCLIN1_RX)
{
IfxAsclin_Spi_isrReceive(&spi);
}

IFX_INTERRUPT(asclin1ErISR, 0, IFX_INTPRIO_ASCLIN1_ER)
{
IfxAsclin_Spi_isrError(&spi);
}

int main( void )
{
// create module config
IfxAsclin_Spi_Config spiConfig;
IfxAsclin_Spi_initModuleConfig(&spiConfig, &MODULE_ASCLIN1);

// set the desired baudrate
spiConfig.baudrate.prescaler = 1;
spiConfig.baudrate.baudrate = 115200; // FDR values will be calculated in initModule

// ISR priorities and interrupt target
spiConfig.interrupt.txPriority = IFX_INTPRIO_ASCLIN1_TX; // see also \ref IfxLld_Asclin
spiConfig.interrupt.rxPriority = IFX_INTPRIO_ASCLIN1_RX; // see also \ref IfxLld_Asclin
spiConfig.interrupt.erPriority = IFX_INTPRIO_ASCLIN1_ER; // see also \ref IfxLld_Asclin
spiConfig.interrupt.typeOfService = IfxCpu_Irq_getTos(IfxCpu_getCoreIndex());
// spiConfig.inputOutput.loopBack = TRUE;
spiConfig.inputOutput.loopBack = FALSE;

// pin configuration
const IfxAsclin_Spi_Pins pins = {
&IfxAsclin1_SCLK_P15_0_OUT, IfxPort_OutputMode_pushPull, // Clock out pin
&IfxAsclin1_RXA_P15_1_IN, IfxPort_InputMode_pullUp, // Rx pin
&IfxAsclin1_TX_P15_4_OUT, IfxPort_OutputMode_pushPull, // Tx pin
&IfxAsclin1_SLSO_P20_8_OUT, IfxPort_OutputMode_pushPull, // Slave select pin
IfxPort_PadDriver_cmosAutomotiveSpeed1
};
spiConfig.pins = &pins;

// install interrupt handlers
IfxCpu_Irq_installInterruptHandler(&asclin1TxISR, IFX_INTPRIO_ASCLIN1_TX);
IfxCpu_Irq_installInterruptHandler(&asclin1RxISR, IFX_INTPRIO_ASCLIN1_RX);
IfxCpu_Irq_installInterruptHandler(&asclin1ErISR, IFX_INTPRIO_ASCLIN1_ER);
IfxCpu_enableInterrupts();

// initialize module
IfxAsclin_Spi_initModule(&spi, &spiConfig);

int i;
for (i = 0; i < SPI_BUFFER_SIZE; i++)
{
spiTxBuffer = i + 65;
spiRxBuffer = 0;
}

// wait until transfer of previous data stream is finished
while( IfxAsclin_Spi_getStatus(&spi) == IfxAsclin_Spi_Status_busy );

// send/receive new stream
IfxAsclin_Spi_exchange(&spi, spiTxBuffer, spiRxBuffer, 8);

for (i = 0; i < SPI_BUFFER_SIZE; i++)
{
spiTxBuffer = 0xFF;
spiRxBuffer = 0;
}
}
0 Likes
0 Replies