AUTOSAR MCAL SPI starting bit bug

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AUTOSAR MCAL SPI starting bit bug

Jump to solution
1,210 Views
pityu
Contributor I

Hi,

I have just noticed a bug inside AUTOSAR MCAL Spi driver when using either Spi_SyncTransmit or Spi_AsyncTransmit. I dont know if it has been fixed yet but everytime, either function is being used (of course after Spi_Init) the first message's starting bit is not right. If I set MSB first the first message is being sent out with LSB and only it is correct after the first message. I also found the potential problem can be in Spi_Ip.c .


In function Spi_Ip_SyncTransmit() there are these lines:

/* Get Lsb value */
LsbValue = State->ExternalDevice->DeviceParams->Lsb ? 1UL : 0UL;
/* Update State structure and internal variables used for timeout */
State->Status = SPI_IP_BUSY;
State->ExternalDevice = ExternalDevice;

So it checks the starting bit before even the ExternalDevice structure is being assigned.

Used package: SW32_RTD_4_4_3_0_2_D2203/Spi_TS_T40D11M30I2R0

0 Kudos
Reply
1 Solution
1,100 Views
Daniel-Aguirre
NXP TechSupport
NXP TechSupport

Hi,

Thanks for the feedback, we could reproduce the issue you are mentioning. It seems this was a bug and was corrected under RTD v4.0.0, the modified code should be the following:

DanielAguirre_0-1694641087217.png

You should be able to modify the function and be able to see it working from the first transaction.

Please, let us know.

View solution in original post

0 Kudos
Reply
3 Replies
1,178 Views
Daniel-Aguirre
NXP TechSupport
NXP TechSupport

Hi,

Are you using any NXP platform? Or is this a custom board?

Also, are you using any example as a base? If so, which configurations are you changing?

We are not seeing any erratas that could explain the behavior you are seeing. Can you share a capture of the transactions on the BUS where it shows the signals?

Please, let us know.

0 Kudos
Reply
1,129 Views
pityu
Contributor I

I am using the S32DS IDE with S32G2 Goldbox Development board. And just using the Spi_Ip_Transfer_S32G274A_M7 example project. The problem wont be seeing by capturing output SPI frames its more like an implementation problem. If I start debugging the project by running the main.c and that line comes which calls Spi_Ip_AsyncTransmit(..) function:

spi_1.png

 

 

 

And this code part is inside Spi_Ip_AsyncTransmit(..) function and as you can see it wants to check the starting bit (MSB or LSB) before even the ExternalDevice structure is being assign which specifies the starting bit.

spi_2.png

This data right now is not correct because these are just default values and not the real values which has been set by the configuration.

spi_3.pngspi_4.png

And a few lines later when the ExternalDevice has been assigned correctly all the relevant values will be updated and after this point should be that check which ask for the starting bit position (if it should be MSB or LSB).

Because the LsbValue variable already exists but with fake value, then the first SPI message will be sent with fake starting bit value and it will be correct only at second frame sending because as the Spi_Ip_apxStateStructureArray is global structure it saves the correct value for later usage.

0 Kudos
Reply
1,101 Views
Daniel-Aguirre
NXP TechSupport
NXP TechSupport

Hi,

Thanks for the feedback, we could reproduce the issue you are mentioning. It seems this was a bug and was corrected under RTD v4.0.0, the modified code should be the following:

DanielAguirre_0-1694641087217.png

You should be able to modify the function and be able to see it working from the first transaction.

Please, let us know.

0 Kudos
Reply