µTasker Forum
µTasker Forum => NXPTM M522XX, KINETIS and i.MX RT => Topic started by: syakovlev on November 16, 2008, 04:18:57 AM
-
Hi all,
To use DMA timer #3 in input capture mode, timer was configured using function
void config_dma_timer_3(void)
{
DMA_TIMER_SETUP ptrSettings; // configuration parameters
ptrSettings.mode = DMA_TIMER_ENABLE_CLOCK_DIVIDER | // DMA timer operation mode
DMA_TIMER_CAPTURE_RISING |
DMA_TIMER_FREERUN |
DMA_TIMER_INTERNAL_CLOCK;
ptrSettings.int_handler = dma_timer3_service; // Interrupt handler to be configured
ptrSettings.int_type = DMA_TIMER_INTERRUPT; // Identifier for when configuring
ptrSettings.int_priority = DTIM3_INTERRUPT_PRIORITY; // Priority the user wants to set
ptrSettings.channel = 3; // DMA timer channel (0..3)
ptrSettings.clock_divider = BUS_CLOCK_DIRECT; // internal bus clock divided by 1
//ptrSettings.count_delay = // count delay until interrupt (clocks or external pulses)
fnConfigureInterrupt(&ptrSettings);
}
Now input capture works perfect, but all attempts to read state of timer_3 input pin failed.
Macros ( PORTIN_SETTC & (1<<3)) always == 1 :( regardless of real state of input (high or low).
GPT timer has GPT_Port_Data_Register (GPTPORT) which could be used to read state of input pin.
Looks like there is nothing similar for DMA timers.
Is it possible at all to do what I want using DMA timers?
Any ideas?
Thanks.
-
Hi
When DTIN3 is used for DMA timer input capture it is programmed from GPIO mode to DTIN mode:
See fnConfigureInterrupt() in M5223x.c:
PTCPAR &= ~(ALT_2_FUNCTION_Q << (iChannel * 2)); // mask first
PTCPAR |= (PRIMARY_FUNCTION_Q << (iChannel * 2));// configure DTIN for capture input
When in this more it is not possible to read the pin state using PORTIN_SETTC (I haven't tried it but your finding suggests it).
Furthermore there is no register in the DMA timer block which returns the present state of the pin.
Therefore I think it will be necessary to program the pin use back to GPIO use, read its state, and then program it back to DTIN use (if required again).
PTCPAR &= ~(ALT_2_FUNCTION_Q << (3 * 2)); // program DTIN3 input back to GPIO function (assumes DDR is already set correctly)
ucPinState = PORTIN_SETTC; // read the input pin value
PTCPAR |= (PRIMARY_FUNCTION_Q << (3 * 2));// configure DTIN3 for capture input use again (if required)
Another possibility is to connect the DTIN3 pin with another (free) GPIO pin and this can be used to read the present state without any restrictions.
Regards
Mark