how to cascade timers

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to cascade timers

1,161 Views
serdar
Contributor I

Hi All,

I am working on K64F board with Kinetis SDK 1.2.0 and trying to read a sensor.

In my application, I need to

1. set a timer to output pulse

2. trigger two ADCs to read inputs by DMA at rising edge

3. go to ISR after 4000 reading

 

I achieved first step . I hope I'll achieve second step after checking examples. But for third step I couldn't solve that how can I cascade timers. I want to connect pulse output timer to another timer as clock input to count up to 4000 and then go to ISR. I used ftm for pulse output.

Which timer module should I use for cascading? I see that cascading is not possible for ftm on datasheet.

 

Thanks in advance,

Serdar

Labels (1)
0 Kudos
4 Replies

775 Views
serdar
Contributor I

HI Xiangjun,

In this case PDB is useless for me. I already generated pulse output with FTM. I need to trigger ADC with FTM. But pulse level is toggling at ever timer overflow and this means pulse period is double timer period. If I trigger ADC with FTM, ADC will sample two times for each pulse output. What do you think?

I may try to reconnect pulse output to a port to trigger ADC if K64 is able to get a pulse from a port as ADC trigger signal. Looking for the reference manual.

I couldn't get your attachment. I may miss a button or something if you didn't forget attach.

Thanks,

Serdar

0 Kudos

775 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Serdar,

For you application to sample two channels at a fixed cycle time, read two sample by DMA, enter ISR after sampling 4000 samples, I think you can use the following solution.

As you know that the K64F has one PDB module and two 16 bits ADC modules, and DMA module, you can set up the PDB so that it can trigger two ADC module at a fixed cycle time, after the ADC conversion is over, the ADC can trigger DMA module so that the DMA can transfer the two samples to memory without core involvement, after the DMA transfer 4000 samples, the DMA can generate interrupt.

For the PDB module, it has 4 channels, the channel0 triggers ADC0, the channel1 triggers ADC1, you can set up the PDB0_MOD to determine the sampling cycle time, set the PDB0_CH0DLY0 to define the ADC0 sampling instant, set the PDB0_CH1DLY0 to define the ADC1 sampling instant. The PDB is set up in software triggering mode instead of external triggering mode.

For the ADC0/ADC1, both of them are set up in hardware triggering mode.

for the DMA, I suppose you can use ONE DMA channel to read both ADC0/ADC1 result registers to memory in the minor loop, you set up the major loop counter as 2000, after 4000 samples has been transferred, the DMA will enter it's own interrupt.

Hope  it can help you.

BR

Xiangjun Rong

0 Kudos

775 Views
serdar
Contributor I

Hi Xiangjun,

Thanks for your answer.

I need to get a pulse to drive sensor. I saw that PDB can generate pulse output in the manual. But I couldn't do it with Processor Expert.

What do you mean with 'major loop counter'? Do you mean I can set number of reading from ADC to memory by DMA to generate interrupt and I can achieve 4000 reading with zero CPU utilizing?

Could you please direct me a detailed PDB example? I am new for Freescale/Kinetis.

Best Regards,

Serdar

0 Kudos

775 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Serdar,

Regarding the "major loop counter", it is a DMA feature, you can set up the DMA major count loop value by setting both the DMA_TCDn_CSR and DMA_TCDn_BITER_ELINKYES, when the defined number of DMA request is reached, the DMA will generate major interrupt.  For detailed inf, pls refer to eDMA chapter.

I attach the PDB plus ADC based on K40, hope it can help you.

Regarding the pulse out generation, unfortunately, the pulse out signal for K64 are connected to on-chip CMP sample/window signal internally, it can not output to an external pad. I suggest you use FTM to generate the pulse.

BR

Xiangjun Rong

0 Kudos