|
|
您好:/ b' L8 H- `2 N1 L) s( T+ d
omapl138光盘demo中的ad7606_dsp程序函数void ad7606_start(ad7606 *ad, unsigned int rate) 做了如下修改,即用TIMER2取代clock, 但是却产生不了 ad7606_on_ticked中断。为什么?
0 X" V( Z# J5 O6 G: Q& y) o9 |' w: C! y. W
|+ ]- p8 K# e9 R. {' R& w5 E# `" q* r! \! p7 R/ [" M
9 }; P+ j3 b6 \# c$ [
$ i1 D& M* n! I4 U4 Ovoid ad7606_start(ad7606 *ad, unsigned int rate) {
; Z5 E) t0 W% Z// ASSERT(ad);) h" I+ Q( \+ O" L
// if (rate > 1000000 / TICK_PERIOD) {! Z4 h4 H9 C# }5 O
// LOG_WARN("unstatisfied sample rate, set as max %d", 1000000 / TICK_PERIOD);
: ^ m8 f# \! B: W; d// rate = 1000000 / TICK_PERIOD;
! G) l5 }! N n// }
9 o0 G) _5 ^, C: n9 j0 C//
! x. ]* ~- N) T" G//
- f& _% q! n2 J& f0 d// int period = 1000000 / TICK_PERIOD / rate;
5 a- k6 k2 @ r$ V" U k9 D6 ^4 H//; k$ @* i* I$ W
// if (! ad->is_running) {
* t$ a" L# j* S$ F// Error_Block eb;$ W$ E8 [9 A+ g2 f- B
// Error_init(&eb);
$ Q% g( x$ I, A" P3 O//) S9 q' Y4 F$ D5 _
// Clock_Params params;6 M7 I( d9 s. C% a/ U' k: @5 O
// Clock_Params_init(¶ms);5 }9 y3 P6 U& U( j! k: Z2 J& j
// params.period = period;
; U! L V* Y/ g/ U6 w// params.arg = (unsigned int)ad;9 E. F8 T$ n1 e. |# l) f/ \
// params.startFlag = TRUE;
9 f, w2 |7 z- s* L9 U7 V- c// ad->clock = Clock_create(ad7606_on_ticked, period, ¶ms, &eb);
0 b+ ]# c( V. m( z r5 c// if (ad->clock == NULL)1 G8 R$ O+ W) o, V( ?5 U, F# I. l
// LOG_FATAL("failed to create clock");6 h8 V- ?& R4 G$ Z! \3 I
//
! s" R6 I- p8 z* G, m% H// Clock_start(ad->clock);
, E0 C( E. B8 P( ^// }
$ R+ t# C7 f( `1 y& h6 f// else {
7 K/ G) _2 R! X7 U. N// Clock_stop(ad->clock);: ^/ s0 z: D3 U
// Clock_setPeriod(ad->clock, period);
8 @ n2 T1 o4 H6 r* w// Clock_start(ad->clock);
1 T4 H4 t; p6 p# G// }
' S9 Y/ l$ l3 u2 O- Y, G0 R# T: w. ?+ ~7 x6 c
// 创建定时器. G- V0 i4 I, _( y$ r: m7 H1 K; O
Timer_Params timerParams;
- Z- d6 N; e4 |& B$ y/ Y Error_Block eb;# }9 w" d+ e! S5 N2 X6 J
) j1 Q( U* B# u# n/ W5 o
// 初始化错误块" e% N- {# Y+ K
Error_init(&eb);
# d6 d; g& _* ?5 T3 L' v // 初始化参数
2 a6 G* a/ n0 g' |9 {2 A Timer_Params_init(&timerParams);
6 L5 k6 b! R0 c N4 K) K S3 {) e& I5 Z. C P
// 配置周期
# q% W. q i7 o timerParams.period = Period;
/ U. f$ Z7 m- p8 N* C: o timerParams.periodType = Timer_PeriodType_MICROSECS;
1 N; q4 y$ L, J1 ~: f' l- \6 q- X
// 实例化定时器
/ J, j0 G$ Z- [( O4 h' O Timer2 = Timer_create(2, ad7606_on_ticked, &timerParams, &eb);6 r& H( C" H6 o: H) V& d
if(Timer2 == NULL)/ D& u& m5 a3 G; \: o
{! c- o) F5 U7 Q# {( J6 J
LOG_INFO("Timer2 not start。。。。");
H, `. t# ?) Q4 ? }# L3 G) {& [8 a/ c
+ x" o. c+ ^" m C7 ]
Timer_start(Timer2);5 N3 Y8 b# @& w$ c" A
1 j5 H) k# v. }5 w, ]3 }
LOG_INFO("Timer2 start。。。。");
. ^; n5 h' d5 i( p9 q: F% P% t
/ G1 H# k9 M0 Q2 G ad->is_running = true;3 t: p# j6 e! y+ m( q3 u1 T( R
}
5 w0 N7 h1 I/ U" T4 R
. d! k$ D2 w+ ^# B! X, k- D0 s |
|