How to read TIM0TCNT reg in s12z

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

How to read TIM0TCNT reg in s12z

415 Views
mikijt
Contributor I

Hi:

 the datasheet mentioned that (as for TCNT) "Write: Has no meaning or effect in the normal mode; only writable in special modes ."what exactly does "special modes" mean? debug mode?

my code:

  uint16_t uValue = (uint16_t)getReg16(TIM0TCNT);
   setReg16(TIM1TCNT,0);
I used to get the timer0 tick count,it works well in debug,but it won't work on its own.
does any one know how to solve the problem?


MIKI

0 Kudos
1 Reply

337 Views
kef2
Senior Contributor IV
  • what exactly does "special modes" mean? debug mode?

Usually we debug in special operating mode. But we can also debug (yes, over BKGD pin) in normal operating mode.

  • 1.7.3 MODC — Mode C signal
  • The MODC signal is used as a MCU operating mode select during reset. The state of this signal is latched
  • to the MODC bit at the rising edge of RESET. The signal has an internal pull-up device.

It is simpler for us if debugger pulls BKGD/MODC low and pulses /RESET low. MCU in this case resets and stops waiting for BDM commands send via BKGD pin. But you may also let debugger connect to already running MCU (in normal mode), then for example perform nonintrusive read of memory or pause execution etc.

TCNT is not writeable in normal operating modes. So your subject is wrong, you read TIM0TCNT well but your write to TIM1TCNT is ignored in normal mode.

Edward

0 Kudos