SPI-2 - Spi Transaction Completed
SPI-2 - Spi Transaction Completed
I need to determine when a SPI transaction has completed. The SPI is transferring single 8 bit message each transaction and doing it in polling mode. There is a SPI_TRANS_DONE interrupt and I am able to read its flag. The problem is that it triggers on the when the Chip Select gets activated, which is after initiating SPI_START and before the transaction actually occurs. The name SPI_TRANS_DONE would indicate that it would be triggered at the end of the transaction when the Chip Select is de-activate but that is not the case. The API doesn't check to see if the transaction has completed and simply waits for a loop timer to expire. Is there any mechanism to determine if the SPI transaction has actually complted?
Thanks
Thanks
-
- Posts: 9727
- Joined: Thu Nov 26, 2015 4:08 am
Re: SPI-2 - Spi Transaction Completed
Do you happen to have code to replicate that?
Re: SPI-2 - Spi Transaction Completed
Yes, Sorry but I don't know how to put it in one of those cool code windows. I use IO pin 10 to trigger the oscilloscope.
CmGpioDedicatedClr10(); // Set IO 10 low.
*SPI_Cmd_Reg_2 = SPI_CMD_REG_USR; // Start the SPI.
while(!((*SPI_Dma_Int_Raw_Reg_2) & SPI_DMA_INT_RAW_BIT_TRANS_DONE)){}; // Wait for Trans done to go high.
CmGpioDedicatedClr10(); // Set IO 10 high.
CmGpioDedicatedClr10(); // Set IO 10 low.
*SPI_Cmd_Reg_2 = SPI_CMD_REG_USR; // Start the SPI.
while(!((*SPI_Dma_Int_Raw_Reg_2) & SPI_DMA_INT_RAW_BIT_TRANS_DONE)){}; // Wait for Trans done to go high.
CmGpioDedicatedClr10(); // Set IO 10 high.
-
- Posts: 1704
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: SPI-2 - Spi Transaction Completed
Do you clear the interrupt flag before starting a transaction?
Re: SPI-2 - Spi Transaction Completed
Yes, forgot to post that. After the
*SPI_Cmd_Reg_2 = SPI_CMD_REG_USR; // Start the SPI.
it takes about 200ns before the interrupt flag gets set which is about 220 to 240ns before the transaction completes.
*SPI_Cmd_Reg_2 = SPI_CMD_REG_USR; // Start the SPI.
it takes about 200ns before the interrupt flag gets set which is about 220 to 240ns before the transaction completes.
-
- Posts: 9727
- Joined: Thu Nov 26, 2015 4:08 am
Re: SPI-2 - Spi Transaction Completed
On which chip is this?
-
- Posts: 1704
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: SPI-2 - Spi Transaction Completed
Ok, so you cleared the interrupt by writing a 1 to its bit in the ...INT_RAW_REG or ...INT_CLR_REG? - And the pointers you're using (SPI_Cmd_Reg_2, SPI_Dma_Int_Raw_Reg_2) are all declared as pointers to volatile?
Last edited by MicroController on Tue Jun 11, 2024 1:56 pm, edited 1 time in total.
Re: SPI-2 - Spi Transaction Completed
Correct, I wrote a 1 to the clear register.
Here are my pointer declarations.
volatile int32_t *SPI_Cmd_Reg_2 = (volatile int32_t *)0x60024000L;
volatile int32_t *SPI_Clock_Reg_2 = (volatile int32_t *)0x6002400CL;
volatile int32_t *SPI_User_Reg_2 = (volatile int32_t *)0x60024010L;
volatile int32_t *SPI_User1_Reg_2 = (volatile int32_t *)0x60024014L;
volatile int32_t *SPI_User2_Reg_2 = (volatile int32_t *)0x60024018L;
volatile int32_t *SPI_Ms_Dlen_Reg_2 = (volatile int32_t *)0x6002401CL;
volatile int32_t *SPI_Misc_Reg_2 = (volatile int32_t *)0x60024020L;
volatile int32_t *SPI_Dma_Int_Clr_Reg_2 = (volatile int32_t *)0x60024038L;
volatile int32_t *SPI_Dma_Int_Raw_Reg_2 = (volatile int32_t *)0x6002403CL;
volatile int32_t *SPI_Dma_Int_St_Reg_2 = (volatile int32_t *)0x60024040L;
Thanks for helping.
Here are my pointer declarations.
volatile int32_t *SPI_Cmd_Reg_2 = (volatile int32_t *)0x60024000L;
volatile int32_t *SPI_Clock_Reg_2 = (volatile int32_t *)0x6002400CL;
volatile int32_t *SPI_User_Reg_2 = (volatile int32_t *)0x60024010L;
volatile int32_t *SPI_User1_Reg_2 = (volatile int32_t *)0x60024014L;
volatile int32_t *SPI_User2_Reg_2 = (volatile int32_t *)0x60024018L;
volatile int32_t *SPI_Ms_Dlen_Reg_2 = (volatile int32_t *)0x6002401CL;
volatile int32_t *SPI_Misc_Reg_2 = (volatile int32_t *)0x60024020L;
volatile int32_t *SPI_Dma_Int_Clr_Reg_2 = (volatile int32_t *)0x60024038L;
volatile int32_t *SPI_Dma_Int_Raw_Reg_2 = (volatile int32_t *)0x6002403CL;
volatile int32_t *SPI_Dma_Int_St_Reg_2 = (volatile int32_t *)0x60024040L;
Thanks for helping.
-
- Posts: 1704
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: SPI-2 - Spi Transaction Completed
Looks all right to me. Haven't checked the addresses though.
We may have to look more deeply into the chip specifics, as @ESP_Sprite implied. So, which SoC are you using?
We may have to look more deeply into the chip specifics, as @ESP_Sprite implied. So, which SoC are you using?
Re: SPI-2 - Spi Transaction Completed
I would also specify
which spi mode is DMA or CPU ?
full duplex or half duplex ?
which spi mode is DMA or CPU ?
full duplex or half duplex ?
Who is online
Users browsing this forum: Baidu [Spider] and 82 guests