The s32k chip has 4x 1588 timer which can capture 1588 time when an external event (edge of an external signal) occurs.
As I understand, the captured timestamps can be read either via SW or by DMA.
Suppose I want to use DMA to read the timestamps and place them in a buffer. Suppose I want to use 2 timers, each of them for different event, and each serviced by different DMA channel. How do I configure each DMA channel to use the particular timer as a trigger source?
I recommend using S32 Design Studio for ARM together with the S32 SDK. You can start from the enet_loopback example and you will be able to configure the pins and the ENET timer through the graphical interface. In order to enable the DMA request for your timer channel, you will need to configure ENET and DMA as follows:
The code initialization sequence should look like this:
ENET_DRV_Init(INST_ETHERNET1, ðernet1_State, ðernet1_InitConfig0, ethernet1_buffConfigArr0, ethernet1_MacAddr);
ENET_DRV_TimerEnableChannel(INST_ETHERNET1, 0U, ðernet1_ChannelInitConfig0);
EDMA_DRV_Init(&dmaController1_State, &dmaController1_InitConfig0, edmaChnStateArray, edmaChnConfigArray, EDMA_CONFIGURED_CHANNELS_COUNT);
EDMA_DRV_ConfigMultiBlockTransfer(0U, EDMA_TRANSFER_PERIPH2MEM, (uint32_t)(&(ENET->CHANNEL.TCCR)), (uint32_t)(buffer), EDMA_TRANSFER_SIZE_4B, 4U, 100U, true);
There is only one DMA request for all the timer channels.
"There is only one DMA request for all the timer channels" - so does it mean that if I have two timers in capture mode, each with different signal, then DMA request for both DMA channels will be triggered whenever any of the two captures takes place? I suppose I can configure the 2 DMA channels to use different timer registers for reading the captured timestamp. But how does triggering the right DMA channel work in this case?
The four timer channels are wired to a single DMA request, thus the DMA channel isn't able to distinguish which timer channel triggers the request.
Option 1: Use software interrupts to have the desired event identification.
Option 2: Use DMA if you wish to copy (any number of) timer channel registers to the desired buffer without direct event identification.