Reply by Art Johnson October 31, 20022002-10-31
All your data looks good. The only thing I can suggest is to stop the program
after it has run for a few seconds, and look at the value in the Timer A0
Control Register, at address X:$0D06 (801/803/805) or address X:$1106 (807).
See if all the bit fields have the correct values, especially the Count Mode
bits (bits 13-15). These bits should have the binary value '001' for the mode
(qtCount) you have selected. Also, the Count Direction (DIR) bit (bit 4) should
be 0 for the direction (qtUp) you have selected. Maybe something is corrupting
the data in the Timer A0 Control Register. The Quad Timer Control Register
(CTRL) is described in Section 14.7.1 in the DSP56F80x User's Manual.

I hope this helps.

Regards,

Art Johnson
Senior Systems Analyst
PMC Prime Mover Controls Inc.
3600 Gilmore Way
Burnaby, B.C., Canada
V5G 4R8
Phone: 604 433-4644
FAX: 604 433-5570
Email:
http://www.pmc-controls.com
-----Original Message-----
From: softoe [mailto:]
Sent: Thursday, October 31, 2002 1:24 PM
To:
Subject: [motoroladsp] Dumb question on quad timers
I am trying to set up a quad timer (A0) to simply count up from 0 to
3125, then reset to 0 and continue counting up. My code is below; for
some reason I can't figure out, the counter counts down instead of
up. What am I doing wrong?

Thanks void initializeRunTaskTimer()
{
qt_sState qtConfig = {
/* Mode = */
qtCount,
/* InputSource = */
qtPrescalerDiv128,
/* InputPolarity = */ qtInverted,
/* SecondaryInputSource = */ 0,
/* CountFrequency = */ qtRepeatedly,
/* CountLength = */
qtUntilCompare,
/* CountDirection = */ qtUp,
/* OutputMode = */
qtAssertOnCompare,
/* OutputPolarity = */ qtNormal,
/* OutputDisabled = */ true,
/* Master = */ 0,
/* OutputOnMaster = */ 0,
/* CoChannelInitialize = */ 0,
/* AssertWhenForced = */ 0,
/* CaptureMode = */ qtDisabled,
/* CompareValue1 = */ 3125,
/* CompareValue2 = */ 0,
/* InitialLoadValue = */ 0,
/* CallbackOnCompare = */ {0, 0},
/* CallbackOnOverflow = */ {0, 0},
/* CallbackOnInputEdge = */ {0, 0}
};
TimerA0_FD = open( BSP_DEVICE_NAME_QUAD_TIMER_A_0, 0, NULL );
ioctl( TimerA0_FD, QT_DISABLE, (void*)&qtConfig );
ioctl( TimerA0_FD, QT_WRITE_COUNTER_REG, 0 );
}

void startRunTaskTimer()
{
qt_sState qtConfig = {
/* Mode = */
qtCount,
/* InputSource = */
qtPrescalerDiv128,
/* InputPolarity = */ qtInverted,
/* SecondaryInputSource = */ 0,
/* CountFrequency = */ qtRepeatedly,
/* CountLength = */
qtUntilCompare,
/* CountDirection = */ qtUp,
/* OutputMode = */
qtAssertOnCompare,
/* OutputPolarity = */ qtNormal,
/* OutputDisabled = */ true,
/* Master = */ 0,
/* OutputOnMaster = */ 0,
/* CoChannelInitialize = */ 0,
/* AssertWhenForced = */ 0,
/* CaptureMode = */ qtDisabled,
/* CompareValue1 = */ 3125,
/* CompareValue2 = */ 0,
/* InitialLoadValue = */ 0,
/* CallbackOnCompare = */ {0, 0},
/* CallbackOnOverflow = */ {0, 0},
/* CallbackOnInputEdge = */ {0, 0}
};

ioctl( TimerA0_FD, QT_WRITE_COUNTER_REG, 0 );
ioctl( TimerA0_FD, QT_ENABLE, (void*)&qtConfig );
}
_____________________________________
Note: If you do a simple "reply" with your email client, only the author of this
message will receive your answer. You need to do a "reply all" if you want your
answer to be distributed to the entire group.

_____________________________________
About this discussion group:

To Join:

To Post:

To Leave:

Archives: http://www.yahoogroups.com/group/motoroladsp

More Groups: http://www.dsprelated.com/groups.php3 ">http://docs.yahoo.com/info/terms/


Reply by softoe October 31, 20022002-10-31

I am trying to set up a quad timer (A0) to simply count up from 0 to
3125, then reset to 0 and continue counting up. My code is below; for
some reason I can't figure out, the counter counts down instead of
up. What am I doing wrong?

Thanks void initializeRunTaskTimer()
{
qt_sState qtConfig = {
/* Mode = */
qtCount,
/* InputSource = */
qtPrescalerDiv128,
/* InputPolarity = */ qtInverted,
/* SecondaryInputSource = */ 0,
/* CountFrequency = */ qtRepeatedly,
/* CountLength = */
qtUntilCompare,
/* CountDirection = */ qtUp,
/* OutputMode = */
qtAssertOnCompare,
/* OutputPolarity = */ qtNormal,
/* OutputDisabled = */ true,
/* Master = */ 0,
/* OutputOnMaster = */ 0,
/* CoChannelInitialize = */ 0,
/* AssertWhenForced = */ 0,
/* CaptureMode = */ qtDisabled,
/* CompareValue1 = */ 3125,
/* CompareValue2 = */ 0,
/* InitialLoadValue = */ 0,
/* CallbackOnCompare = */ {0, 0},
/* CallbackOnOverflow = */ {0, 0},
/* CallbackOnInputEdge = */ {0, 0}
};
TimerA0_FD = open( BSP_DEVICE_NAME_QUAD_TIMER_A_0, 0, NULL );
ioctl( TimerA0_FD, QT_DISABLE, (void*)&qtConfig );
ioctl( TimerA0_FD, QT_WRITE_COUNTER_REG, 0 );
}

void startRunTaskTimer()
{
qt_sState qtConfig = {
/* Mode = */
qtCount,
/* InputSource = */
qtPrescalerDiv128,
/* InputPolarity = */ qtInverted,
/* SecondaryInputSource = */ 0,
/* CountFrequency = */ qtRepeatedly,
/* CountLength = */
qtUntilCompare,
/* CountDirection = */ qtUp,
/* OutputMode = */
qtAssertOnCompare,
/* OutputPolarity = */ qtNormal,
/* OutputDisabled = */ true,
/* Master = */ 0,
/* OutputOnMaster = */ 0,
/* CoChannelInitialize = */ 0,
/* AssertWhenForced = */ 0,
/* CaptureMode = */ qtDisabled,
/* CompareValue1 = */ 3125,
/* CompareValue2 = */ 0,
/* InitialLoadValue = */ 0,
/* CallbackOnCompare = */ {0, 0},
/* CallbackOnOverflow = */ {0, 0},
/* CallbackOnInputEdge = */ {0, 0}
};

ioctl( TimerA0_FD, QT_WRITE_COUNTER_REG, 0 );
ioctl( TimerA0_FD, QT_ENABLE, (void*)&qtConfig );
}