Hi all,
this is my first post and I hope someone can help me to solve this very strange problem I'm struggling to for about 2 months now.
I'm trying to control some data exchange via GPIOs without the use of bit-banging (it's a custom protocol I'm working on for my customer, which is not using any of standard buses like I2C, SPI, UART and so on) more or less like a "multi" onewire protocol.
To achieve this, I'm developing a custom driver based on driverlib, since no high level driver can be used for the purpose, basically I'd like to use the Scatter-Gather DMA transfer by creating a task list of DMA requests each driving directly a separate GPIO by writing '1' or '0' directly on the GPIO data register.
To avoid CPU usage (I have very strict constraints related to power management), I want to drive the DMA by using a timer, in this way, using the Peripheral Scatter-Gather mode, I can use the timeout interrupt of the timer to trigger each of the DMA tasks and control the GPIO in sync with the timer without the need to process anything using the CPU or use software delays to respect the protocol timings.
What I want to achieve is control the communication by simply starting the timer which triggers the DMA requests one task at a time (so it can drive a single GPIO high or low according to the protocol) and terminate it by stopping the timer without any CPU intervention (so an entire message can be sent enabling and disabling the timer within a specific amount of time).
As reference for my code I used this document: "CC13x2, CC26x2 SimpleLink Wireless MCU Technical Reference Manual", where the Peripheral Scatter-Gather DMA is described in par. 14.3.6.6 and the timer triggered DMA request feature is described in par. 15.4.5. and as reference code for the configuration of timer and DMA I used also the ADCBufCC26X2 driver which uses a ping-pong based mode DMA management and the timer triggers the ADC instead of directly the DMA.
I'm using GPTimer 0 configured as 16bit continuous upcounting timer and channel 9 of DMA (which is triggered by the timeout event of GPT0).
Everything seems to work quite well, except that I can see the data flow only when I have the firmware running with the debugger attached (I use a Launchpad CC1352R1 eval board), while if I run it without debugging the DMA stops working (same firmware built with debug profile no optimizations).
I did some tests using also a logic analyzer to display the status of the signals and adding some other GPIOs used as test signals to collect information regarding the state of the timer and if the interrupts are triggered correctly. I also have a UART console I can use to access registers in order to set/get values of registers to see what happens when I'm not attached with the debugger.
I discovered the main difference is the REQDONE state of the DMA, precisely: when I activate the timer and the DMA starts processing the Scatter-Gather task list, if I have the firmware running with the debugger attached, the REQDONE NEVER occurs and everything works flawlessly; on the contrary if I simply press the "Stop" button in the IDE or if I run the firmware directly without debugger attached, after the first task or at most the second one, the REQDONE is raised and the DMA stops processing the rest of the tasks stopping the sequence.
My question is: is this an expected behavior? Is there something different I need to configure to avoid such event to occur when I run the firmware without the debugger?
For NDA reasons (I'm a consultant for my customer) I cannot provide full source code of the project, but if necessary I can copy/paste here some parts related strictly to the configuration of DMA and Timer; anyway to provide a sample of the expected outcome I attach two screenshots of my logic analyzer output, the first with the correct behavior (2 GPIOs and the timer toggling trace as reference) and the bad behavior (I registered a HWI/SWI couple attached to the timer interrupt and in the SWI I simply reenable the DMA channel if the REQDONE flag raises, but this creates gaps in the protocol because the HWI is triggered randomly so I loose some DMA transactions).
Sorry for the long text, I wanted to provide as many information as possible, thank you very much in advance for any suggestion.
Dario
