Hi Alexis,
The claim you made is as following:-
When the first time interruption is called, one byte is already sent.
It is incorrect because we have verified it while debugging by putting a breakpoint inside the interrupt, we found that when the first interrupt happens the following command is used to push 1st byte of data into FIFO buffer, not the second byte as per the claim.
SPI_PDD_WriteMasterPushTxFIFOReg(SPI1_BASE_PTR, (uint32_t) ( * ( (uint8_t *) DeviceDataPrv->OutDataPtr++) | DeviceDataPrv->TxCommand) );
But let us try to assume the claim is true and logically try to verify w.r.t to the configuration and the actual code generated by processor expert:-

I think you haven't understood my previous reply about the interrupt. So I explaining it again here, the interrupt that is configured by processor expert is not the transmission complete interrupt but it is the buffer not full interrupt. This can be verified from the Flag mask that is used to configure and check the interrupt status in the code:-
The value of SPI_PDD_TX_FIFO_FILL_INT_DMA is 0x02000000 which is equal to 0b00000010000000000000000000000000 in binary, so it is used to mask the 25th bit
| 32 | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Now consider the Interrupt Status Register, the 25th bit is mapped to TFFF Flag which is raised once the FIFO buffer is empty.

We can also see why the claim is false by logically verifying the code:-
Lets assume that the claim is true, so when the first time the interruption is called for transmitting data, the execution happens in the marked code snippet shown below.

Lets say we have 2 bytes of data to be transmitted using SPI which is {0x01, 0x02} for analysys:-
Step 1:- The code executes only if this line is true, since the assumption is that the first byte was transmitted, the buffer is not full and the if condition is true
if (StatReg & SPI_PDD_TX_FIFO_FILL_INT_DMA) ! = 0U)
Step 2:- The next condition is also true since only 1 byte is transmitted, i.e the byte transmitted is lesser than bytes requested to transmit.
if (DeviceDataPrv->OutSentDataNum < DeviceDataPrv->OutDataNumReq)
Step 3:- In this line the variable that keeps track of the number of bytes that is sent gets incremented, so now:-
DeviceDataPrv->OutSentDataNum++
- since the claim was 1 byte was already sent (which is 0x01), this gets incremented to value 2 which is wrong because it should have incremented after the transmission according to the claim.
DeviceDataPrv->OutSentDataNum++
Step4:- The command is supposed to push a byte of data from the array pointer to the FIFO Register.
SPI_PDD_WriteMasterPushTxFIFOReg(SPI1_BASE_PTR, (uint32_t) ( * ( (uint8_t *) DeviceDataPrv->OutDataPtr++) | DeviceDataPrv->TxCommand) );
- So if the claim is 1 byte of data is already transmitted in first interrupt, then how did the pointer got incremented to point to the second byte? So again there is a problem. Lets say it somehow got incremented to point to second data, now when it is incremented again, it will be pointing to the 3rd byte.
- Previously in Step 3 we assumed that OutSentDataNum it is incremented to 1 from 0 and because of this in the next interrupt Step 1 is true, Step 2 is also true, Step 3 OutSentDataNum is incremented to 2 and in Step 4 we are trying to access the 3rd byte and so the system will throw Bus Fault.
What is the explanation for the issues that I have mentioned in Red with that claim.
Regards,
Prajwal B V