Hi to you all,
I'm currently working on a project involving the LPC-Link2 as a eval. board for it's LPC4370 (for a complete explanation see this question).What I'm trying to do is:
At the moment I managed to be fine with the first 2 bullets, my question is: what is the fastest (and most elegant) way to process data without loosing (too much) samples and whitout interferring with DMA activity?I tried the following procedure:
BUT, it seems that I'm haviong troubles because of the cortex M4 ISR overhead. A drawing will better explain this:
The * in the image means:
How do I solve this? If anything isn't that clear I will be happy to explain it better.
Any help would be highly appreciated!
Regards,
Andrea
I think that your suggestions are good Thibaut, especially about the fact that hardware flags can do the trick.Right now I looked at the timer manual and I can trigger DMA transfers from timers: that should not be difficult, but still, I don't know how to catch the position in the buffer.Just to clarify.This DMA works with Linked List: objects that specify the characteristics of each transfer. I have now 2 linked lists pointing to each other and continuously being called one after the other. That's how I fill my sub-buffers. I searched for minor/major loops in the docs, but no luck. Option 1 should be feasible, even if I don't know at the moment how to configure the DMA for this.
What is not clear to me is: how do I relate (without using software) a constant array in RAM/ROM with the position being accessed by the DMA in another array in RAM/ROM?
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ Timer 1 @ f1 | | | | | | | | | | | ^ ^ ^ Timer 2 @ f2/4 | | | last sample position 0 1 2 3 4 5 6 7 8 9 ... last transfered index 255 0 1 ... ^ ADCHS comparison Interrupt | index = 0 sample_position = index * 4
Hi Thibaut, sorry for me being this late, but I'm attending lessons every day at university right now and I'm a bit busy. Nevertheless I must keep this project alive.Absolutely useful picture on what the firmware should do, thanks Thibaut. Hopefully I'll be able to test it with "real" signals soon enough.Therefore I'm trying to implement the timer triggered memory-to-memory DMA transfer. Unfortunately that's not easy to me. At the moment I have one main problem.
Connect the DMA channel to the timer, to use it (the timer) as a trigger: I looked at an LPCOpenV2.20 example, but I think is not working. Also, after writing the function to setup the timer and trigger the DMA, they kindly commented it. Nice one. This is the setup:
/* Setup DMA M2M transfer to trigger on timer match */ static void setupDMATrigger(void) { /* Initialize GPDMA controller */ Chip_GPDMA_Init(LPC_GPDMA); /* Get DMA channel */ dmaCh = Chip_GPDMA_GetFreeChannel(LPC_GPDMA, GPDMA_CONN_MAT0_0); /* Setup DMA transfer */ Chip_GPDMA_Transfer(LPC_GPDMA, dmaCh, (uint32_t) &source[0], GPDMA_CONN_MAT0_0, //(uint32_t) &dest[0], GPDMA_TRANSFERTYPE_M2M_CONTROLLER_DMA, sizeof(source)); // Chip_GPDMA_Stop(LPC_GPDMA, dmaChSSPTx); /* Enable GPDMA interrupt */ NVIC_EnableIRQ(DMA_IRQn); }
int main(void) { int numDmaXfers = 0; SystemCoreClockUpdate(); Board_Init(); /* Setup tiemr capture input used for DMA trigger */ setupTimerCapInput(); /* Setup timer for match event on each capture event */ setupTimerTrigger(); /* Setup DMA for memory to memory transfer on timer match event */ // setupDMATrigger(); /* Enable timer interrupt */ NVIC_EnableIRQ(TIMER0_IRQn); NVIC_ClearPendingIRQ(TIMER0_IRQn); /* Idle in background waiting for DMA events */ while (1) { ... etc...
Hi Thibaut, I saw in the past few months that this microcontroller is really rarely used and (I think) a bit underrated. I feel somewhat lost in trying to understand how it works. Anyway, maybe I'll just switch back to my previous solution as you said, but I'm also considering to purchase from NXP a Pro licence to have 1 year of email support. I'd really like to thank you for the help and I won't forget to update this post if I'll get this thing work.All the best,Andrea