Newbie - Starting a timer and reading timer counter TCN on a 68302

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

Newbie - Starting a timer and reading timer counter TCN on a 68302

1,284 Views
eSteve
Contributor I
I am trying to start timer2 and read the timer counter value (TCN2), once I have started the timer I am expecting to the see the TCN2 value incrementing, but I see no change in the TCN2 value.  I am starting the timer thus:
 
/* This is the timer 2 mode register set up -
   000B hex, 11 decimal or
   0000 0000 0000 1011 binary -
   PS   = (0000 0000) divide the clock by 1,
   CE   = (00) disable int on capture,
   OM   = (0) active low pulse for one clock cycle (62.5ns),
   ORI  = (0) enable interrupt on reaching reference val,
   FRR  = (1) reset count on timeout,
   ICLK = (01) source - master clock,
   RST  = (1) enable timer */

#define SETTIMER2MODE 0x000B
#define TCN2  0x856
#define TMR2  0x850
 
/* Set up the timer 2 mode register */
Poke16(BASE + TMR2, SETTIMER2MODE);
 
Poke is a library function, which works since I can see the value 0x000B at the address of 0x850 + BASE
 
So as I understand it Timer2 should now be running and will roll round when it reaches 65535.
 
When running in the simulator I then examine TNC1 expecting it to be incrementing in time with the clock but there is no value at TCN2.
 
What's wrong?  Any ideas anyone?  Thanks.
 
Compiler - Cosmic IdeaCPU32
Simulator - Cosmic ZAP
Labels (1)
0 Kudos
2 Replies

328 Views
eSteve
Contributor I
taigbr,
 
thanks for your help, I have jiggled it around some what, bearing in mind your comments, however I am not certian the emulator is correctly simulating the timers so will try it on some hardware.
 
Kalvin
0 Kudos

328 Views
taigbr
Contributor I
Hi Kalvin,

I think you misunderstood the bit FRR. It resets the counter to the refvalue
So depending on the refvalue the counter value might seem to stay the same.
I would suggest:
- stop the timer
- set the refvalue
- start the timer
Regards, Georg
.
0 Kudos